logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thad Humphries <thad.humphr...@gmail.com>
Subject Changing log4jConfiguration context-param with Tomcat 8
Date Tue, 22 Sep 2015 17:26:34 GMT
I am adding Log4j 2 to an existing webapp. I am required to allow users to
put the logger's configuration file wherever they wish, and to write their
log files wherever and however they wish.

I have used Log4j 1 in other webapps. There I alter the logging properties
in a Listener by calling PropertyConfigurator.configure() on whatever file
was named in the webapp's context as "log4j-init-file" (in Tomcat, the
webapp's META-INF/context.xml file). I am using Log4j 2.3 and Tomcat 8.0.22.

Log4j 2 does not allow configuring with PropertyConfigurator. From the
documentation, I had thought that if I set
org.apache.logging.log4j.web.Log4jServletContextListener as the first
<listener> in the web.xml, and added the <filter>, <filter-mapping>, and
<context-params> described in
https://logging.apache.org/log4j/2.0/manual/webapp.html for a Servlet 2.5
app, I could then override the log4jConfiguration
in META-INF/context.xml with

    description="Log4j 2.x configuration file."

This is not working for me. The app is still using the values set by the
log4jConfiguration in web.xml. I have tried using a file path and a file://
URI. I am starting Tomcat and own myweblog.xml so permissions should not be
the problem (and the Log4j 1.x properties files can be read by their apps).

What am I missing or misunderstanding? How can I accomplish what I could do
in Log4j 1.x?

"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v. 121-24)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message