
Hi, I am using external properties file(process_settings.properties) for variable substitution to programmatically configure the following logger parameters: BACKUP_COUNT (backup history) FILE_SIZE LOG_LEVEL
From my application, after I set the above mentioned params in properties file, I want the logback configuration(and hence the new properties file) to be reloaded and restarted again.
For that I am doing: LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); loggerContext.reset(); ContextInitializer ci = new ContextInitializer(loggerContext); ci.autoConfig(); On restart, logback.xml is not using the updated properties file, instead it is still substituting values which were set previously. Please suggest how to restart logback such that the updated properties file is picked up. (Properties file is being correctly updated – this has been verified) Logback.xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <property resource="process_settings.properties" /> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder <encoder> <pattern>%d [%thread] %-5level %class{0} %msg%n</pattern> </encoder> </appender> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>C:/cpm.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <!-- <fileNamePattern>/var/log/cloudprovider-mgr/cpm.%i.log</fileNamePattern> --> <fileNamePattern>C:/cpm.%i.log</fileNamePattern> <minIndex>1</minIndex> <maxIndex>${BACKUP_COUNT}</maxIndex> </rollingPolicy> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <maxFileSize>${FILE_SIZE}</maxFileSize> </triggeringPolicy> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %class{0} %msg%n</pattern> </encoder> </appender> <root level="DEBUG"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> <logger name="com.xyz"> <level value="${LOG_LEVEL}" /> </logger> </configuration> Thanks, Kriti =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you