Configure Oracle Weblogic to use log4j

As we said, by default Oracle Weblogic server use the JDK Logging implementation. You can anyway switch to Log4j ( configuration if you feel more comfortable with it. That will anyway require a few steps to complete it:

1.       At first, from the Advanced Logging screen, select Log4j as the Logging implementation as shown by the following picture:

oracle weblogic book oracle weblogic books

2.       Now enter your Server’s configuration screen and select Configuration | Server Start. From there, add as properties the log4j configuration file name and set the property weblogic.log.Log4jLoggingEnabled to true as shown by the following snapshot:

oracle weblogic book oracle weblogic books

Remember that the (or log4j.xml) file needs to be included into Weblogic classpath; thus, supposing that you have placed it into the folder “C:\Weblogic\user_projects\domains\base_domain\config”, then you need adding this directory into the server Classpath text item.

The following defines a RollingFileAppender which will write logs to your domain root directory:(C:\Weblogic\user_projects\domains\base_domain)





log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout

log4j.appender.rollingFile.layout.ConversionPattern=%p %t %c - %m%n

log4j.rootLogger = INFO, rollingFile

 Last effort, since WebLogic Server does not load any Log4j library in your domain, will be to include log4j in the DOMAIN_HOME/lib subdirectory. Place there a Log4j implementation (log4j-X.X.X) and Weblogic’s Log4j libraries (wllog4j.jar) which are part of the server distribution.  

Are we living in a simulated reality? Check it here!
Francesco Google+