[logback-user] How to reload logback configuration ?

Kriti Wadhwa kriti.wadhwa at tcs.com
Tue Jul 9 14:21:50 CEST 2013


I am using external properties file(process_settings.properties) for variable substitution to programmatically configure the following logger parameters:
BACKUP_COUNT (backup history)
>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();
ContextInitializer ci = new ContextInitializer(loggerContext);
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)  
<?xml version="1.0" encoding="UTF-8"?>
       <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
                     <pattern>%d [%thread] %-5level %class{0} %msg%n</pattern>
       <appender name="FILE"
              <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">                    
                     <!-- <fileNamePattern>/var/log/cloudprovider-mgr/cpm.%i.log</fileNamePattern> -->
              <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
                     <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %class{0} %msg%n</pattern>
       <root level="DEBUG">
              <appender-ref ref="STDOUT" />
              <appender-ref ref="FILE" />
<logger name="com.xyz">
              <level value="${LOG_LEVEL}" />
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130709/bfcc499b/attachment-0001.html>

More information about the Logback-user mailing list