https://docs.oracle.com/cd/E23943_01/web.1111/e13739/logging_services.htm#WLLOG199
To redirect messages from JDK logging system to WebLogic standard log files we need to add special ServletLoggingHandler.
logging.properties:
# Specify the handlers to create in the root logger
handlers = weblogic.logging.ServerLoggingHandler
# Register handlers for the com.foo.toyshop and its child loggers
com.foo.toyshop.handlers = java.util.logging.ConsoleHandler, weblogic.logging.ServerLoggingHandler
# Do not send the toyshop log messages to the root handler
com.foo.toyshop.useParentHandlers = false
# Set the default logging level for the root logger
.level = ALL
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = INFO
# Set the default logging level for new FileHandler instances
weblogic.logging.ServerLoggingHandler.level = ALL
We have to add the following argument for JVM to start using our properties file.
java -Djava.util.logging.config.file=C:\mydomain\logging.properties weblogic.Server
If we want to put our custom logging.properties into jar or war archive, we have to load it programmatically:
private void initLogging() {
InputStream inputStream = this.getClass().getResourceAsStream("/logging.properties");
try
{
LogManager.getLogManager().readConfiguration(inputStream);
System.out.println("Logging initialized");
}
catch (final IOException e)
{
Logger.getAnonymousLogger().severe("Could not load default logging.properties file");
Logger.getAnonymousLogger().severe(e.getMessage() );
}
}
|