Skip to content

Commit

Permalink
Use DefaultJoranConfigurator
Browse files Browse the repository at this point in the history
Signed-off-by: Gerben Kroes <[email protected]>
  • Loading branch information
kroesctrl committed Jan 24, 2024
1 parent 5c0f70e commit 096f514
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package org.opensmartgridplatform.shared.application.config;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.util.DefaultJoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -110,17 +110,17 @@ private Optional<String> getLogConfigLocation(

private void initializeLoggingContext(final String location)
throws FileNotFoundException, JoranException {
final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
final var loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

// in the current version logback automatically configures at
// startup the context, so we have to reset it
final JoranConfigurator configurator = new JoranConfigurator();
final var configurator = new DefaultJoranConfigurator();
configurator.setContext(loggerContext);
loggerContext.reset();

// reinitialize the logger context. calling this method allows
// configuration through groovy or xml
configurator.doConfigure(ResourceUtils.getURL(location)); // <<< REPLACE THE FILENAME
// configuration through xml
configurator.configureByResource(ResourceUtils.getURL(location));
this.logger.info("Initialized logging using {}", location);
}
}

0 comments on commit 096f514

Please sign in to comment.