Search code examples
weblogic

Log4J Application Specific Configuration file in Weblogic


My setup includes a weblogic 12c server which hosts several applications. The application which i am writing has log4j configuration property with appenders that are specific to this application. I have packaged the property in app EAR and deployed it to weblogic.

I want the log4j setup in weblogic to pull configuration from this property file. Will i still need a global configuration file put in inside the domain root folder? . The thing that confuses me is, why do i need to have log4j configuration in domain root if i already have it inside the application ( while i load using PropertyConfigurator) .

I did copy the log4j and wllog jars to domain/lib but i am not happy with copying anything to server directories since i want this to be driven by the deployed EAR.

I am new to Weblogic so might be something obvious. Tried several links on the web but none of them answers my question. I have been referring to this thread for the setup. https://community.oracle.com/thread/1063248


Solution

    1. Make sure log4j jar is in APP-INF/lib
    2. Make sure your log4j config file is in the root classpath for the ear (APP-INF/classes)
    3. If you don't have one already, add a weblogic-application.xml (see http://docs.oracle.com/cd/E24329_01/web.1211/e24368/app_xml.htm#WLPRG389) to your META-INF directory at the EAR level, and in there include a prefer-application-packages element with package-name of org.apache.log4j