3
votes

I am deploying an EAR application on Weblogic 12c. I am looking to configure log4j2 and putting the following in web.xml (of the web project) is not working (file is not picked up by the application).

<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:///webapps/apps/appName/log4j2.xml</param-value>
</context-param>

I get the error

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

If i mention the path to the log4j2.xml file in the weblogic startup script (-Dlog4j.configurationFile=path/to/log4j2.xml ), it picks up the log4j file. How can I get the <context-param> setting to work? I am running weblogic from within Eclipse (STS).

1

1 Answers

1
votes

Just to double-check: have you added the log4j-web dependency to the classpath? Without that the context parameter won't work.

Also, be aware that the specified file: path will be resolved relative to the web context root. Essentially it will return the result of ServletContext.getResource(path).

You may be able to see what is going wrong if you set system property -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE. That will print internal Log4j2 logging to the console.