Logback config with properties

Brent Putman putmanb at georgetown.edu
Fri Jun 20 11:49:45 EDT 2014


>From the call...

Here is some sample code for using programmatic properties with
Logback.  For example, our LogbackLoggingService could be injected with
a Properties instance, and then code similar to this would go in
loadLoggingConfiguration..

      
               loggerContext.reset();
                
                if (properties != null) {
                    statusManager.add(new InfoStatus("Setting supplied
properties on LoggerContext", origin));
                    Enumeration<?> propNames = properties.propertyNames();
                    while (propNames.hasMoreElements()) {
                        String propName = (String) propNames.nextElement();
                        statusManager.add(new InfoStatus(
String.format("Setting LoggerContext property name: '%s', value: '%s'",
                                propName,
properties.getProperty(propName)), origin));
                        loggerContext.putProperty(propName,
properties.getProperty(propName));
                    }
                }
        
                JoranConfigurator configurator = new JoranConfigurator();
                configurator.setContext(loggerContext);
                configurator.doConfigure(is);
                loggerContext.start();
                
                Logger log = LoggerFactory.getLogger(LoggingHelper.class);
                log.debug("Successfully loaded Logback configuration
file: {}", configFilename);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20140620/b977f75e/attachment.html 


More information about the dev mailing list