Md Faraz
Md Faraz

Reputation: 317

log4j and Weblogic Server : Logs not getting generated

I have multiple ears,For certain Ears I want log4j details to be picked from Weblogic level and for certain application I have application level log4j.xml bundled with ear.

  1. Copied wllog4j.jar and Log4j-x.x.x.jar to Server classpath
  2. Added the following JAVA_OPTION in

startWebLogic.sh -Dlog4j.Configuration=Mylog4j.xml

and add the "Mylog4j.xml" in the Server Classpath as :

    SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}" -Dlog4j.Configuration=Mylog4j.xml
    SAVE_CLASSPATH="${CLASSPATH}:/apps/myfiles/MyLog4j.xml" 
  1. For application which have application level log4j.xml ,I have mentioned prefer-application-packages in weblogic-application.xml

    <prefer-application-packages>
    <package-name>org.apache.log4j.*</package-name> 
    </prefer-application-packages>
    

But the logs are not getting generated for those application which has there log4j.xml

Also,Just for info : Applications are using slf4j/commons-logging and log4j

Please suggest !!!

Upvotes: 0

Views: 7145

Answers (2)

user5164546
user5164546

Reputation: 1

Follow below steps 1) copy log4j.jar and wllog4j.jar in server lib folder 2) copy your log4j.xml in server domain folder 3) change setDomaninEnv.xml to point to your log4j.xml file ex: LOG4J_CONFIG_FILE="${DOMAIN_HOME}/log4j.xml"

Upvotes: 0

Md Faraz
Md Faraz

Reputation: 317

The issue was related to classloading : Below line in weblogic-applicaton.xml does the trick.

    <prefer-application-packages>
     <package-name>org.apache.log4j.*</package-name> 
     <package-name>org.apache.*</package-name> 
     <package-name>org.slf4j.*</package-name> 
    </prefer-application-packages>

Upvotes: 1

Related Questions