I recently spent several days trying to track this down why Apache log4j for my Java application was working when deployed to Oracle WebLogic Server 10.3.5.
I am posting my findings here in the hopes of saving others some time.
I found several blogs that talked about this, but the end result was
that log4j was still not working correctly. There was always one step
missing. A co-worker and I finally figured it out for both Linux and
Windows.
1. Copy wllog4j.jar from your WebLogic server/lib directory and place it in your domain_root/lib folder.
2. Copy your version of log4j.jar to your domain_root/lib folder.
3. Copy your log4j.xml to your domain_root folder.
4. Log in to the your WebLogic admin server console. Click on Servers -> Admin Server -> Logging. Click on advanced mode, and change the logging implementation from JDK to Log4J. Save your changes.
Most of the blogs had these items, but the one critical piece that was missing:
5. (Linux)Edit the setDomainEnv.sh file in the domain_root/bin directory. and find the following code:
Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:
5. (Windows)
Edit the setDomainEnv.cmd file in the domain_root/bin directory. and find the following code:
Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:
6. Activate the changes and restart the admin server.
Here is a sample log4j.xml file. Obviously, you will need to update it for a valid location for your file appender, and replace yourcompany and yourproject with valid values.
Again, I hope that this will save someone the pain I went through to track this down.
1. Copy wllog4j.jar from your WebLogic server/lib directory and place it in your domain_root/lib folder.
2. Copy your version of log4j.jar to your domain_root/lib folder.
3. Copy your log4j.xml to your domain_root folder.
4. Log in to the your WebLogic admin server console. Click on Servers -> Admin Server -> Logging. Click on advanced mode, and change the logging implementation from JDK to Log4J. Save your changes.
Most of the blogs had these items, but the one critical piece that was missing:
5. (Linux)Edit the setDomainEnv.sh file in the domain_root/bin directory. and find the following code:
if [ "${LOG4J_CONFIG_FILE}" != "" ] ; then
JAVA_PROPERTIES="${JAVA_PROPERTIES} -Dlog4j.configuration=file:${LOG4J_CONFIG_FILE}"
export JAVA_PROPERTIES
fi
Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:
LOG4J_CONFIG_FILE=”/u01/app/oracle/middleware/user_projects/domains/base_domain/log4j.xml”
Export LOG4J_CONFIG_FILE
5. (Windows)
Edit the setDomainEnv.cmd file in the domain_root/bin directory. and find the following code:
if NOT "%LOG4J_CONFIG_FILE%"=="" (
set JAVA_PROPERTIES=%JAVA_PROPERTIES% -Dlog4j.configuration=file:%LOG4J_CONFIG_FILE%
)
Insert the following above those lines of code(replacing the path with the one for your system's domain_root directory:
set LOG4J_CONFIG_FILE=”C:\Oracle\Middleware\user_projects\domains\base_domain\log4j.xml”
6. Activate the changes and restart the admin server.
Here is a sample log4j.xml file. Obviously, you will need to update it for a valid location for your file appender, and replace yourcompany and yourproject with valid values.
Again, I hope that this will save someone the pain I went through to track this down.
No comments:
Post a Comment