Search in sources :

Example 1 with LoggingReloadedApplicationEvent

use of com.kixeye.chassis.support.events.LoggingReloadedApplicationEvent in project chassis by Kixeye.

the class LoggingConfiguration method reloadLogging.

/**
	 * Reloads logging.
	 * 
	 * @param logbackConfig XML containing the logback configuration
	 */
public void reloadLogging(String logbackConfig) {
    LoggerContext logContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(logContext);
        logContext.reset();
        configurator.doConfigure(new ByteArrayInputStream(logbackConfig.getBytes(Charsets.UTF_8)));
    } catch (JoranException je) {
    // StatusPrinter will handle this
    } catch (Exception ex) {
        // Just in case, so we see a stacktrace
        ex.printStackTrace();
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(logContext);
    applicationContext.publishEvent(new LoggingReloadedApplicationEvent(this));
}
Also used : LoggingReloadedApplicationEvent(com.kixeye.chassis.support.events.LoggingReloadedApplicationEvent) ByteArrayInputStream(java.io.ByteArrayInputStream) JoranException(ch.qos.logback.core.joran.spi.JoranException) JoranConfigurator(ch.qos.logback.classic.joran.JoranConfigurator) LoggerContext(ch.qos.logback.classic.LoggerContext) JoranException(ch.qos.logback.core.joran.spi.JoranException)

Aggregations

LoggerContext (ch.qos.logback.classic.LoggerContext)1 JoranConfigurator (ch.qos.logback.classic.joran.JoranConfigurator)1 JoranException (ch.qos.logback.core.joran.spi.JoranException)1 LoggingReloadedApplicationEvent (com.kixeye.chassis.support.events.LoggingReloadedApplicationEvent)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1