Configuring log4j on weblogic server for web applications.

Posted by adejuanc on Oracle Blogs See other posts from Oracle Blogs or by adejuanc
Published on Tue, 9 Oct 2012 21:57:32 +0000 Indexed on 2012/10/10 3:46 UTC
Read the original article Hit count: 292

Filed under:
To configure Weblogic server :

1.- Read the following link :
How to Use Log4j with WebLogic Logging Services

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/logging/config_logs.html#wp1014610


Here the step by step :

2.- Go to WL_HOME/server/lib and copy wllog4j.jar to the server CLASSPATH, to do this copy the file into DOMAIN_NAME/lib
3.- Download log4j jar (in my case I had not the file) from http://logging.apache.org/log4j/1.2/download.html , in this case the last available version is log4j-1.2.17.jar, and copy the file into DOMAIN_NAME/lib (As step 2).
4.- In this case I activate log4j using WLST (Weblogic Scripting Tool), as bellow :

4.1 .- As you're using windows, execute a terminal window and go to DOMAIN_NAME/bin and run the file setDomainEnv.cmd (this file will set the environment to run java).
4.2 .- Execute the following comands :


C:\>java weblogic.WLST
wls:/offline> connect('username','password')
wls:/mydomain/serverConfig> edit()
wls:/mydomain/edit> startEdit()
wls:/mydomain/edit !> cd("Servers/$YOUR_SERVER_NAME/Log/$YOUR_SERVER_NAME";)
wls:/mydomain/edit/Servers/myserver/Log/myserver !> cmo.setLog4jLoggingEnabled(true)
wls:/mydomain/edit/Servers/myserver/Log/myserver !> save()
wls:/mydomain/edit/Servers/myserver/Log/myserver !> activate()


you can use ls() to list the objects under the WLS directory

this will activate log4j to use it with WLS.



Configuring WebLogic Logging Services


http://download.oracle.com/docs/cd/E12840_01/wls/docs103/logging/config_logs.html

To configure applications :

1. Create a log4j.properties file as bellow


log4j.debug=TRUE
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/home/server.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSSS} %p %t %c – %m%n

2. Copy the file to /WEB-INF/classes directory. of your application.

3.- implement also the last action provided to activate log4j on WLS

© Oracle Blogs or respective owner

Related posts about /Oracle