-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 9/10/2014 8:40 AM, sbre...@hotmail.com wrote:
> Hello
> 
> We have a setup which compiles WAR applications once and deploys 
> them in various environments. Each environment has its own per 
> application Log4j configuration (WARN for production, DEBUG for 
> development etc.) which should survive application redeployment.
> 
> So far the solution is:
> 
> webapps/myapp/WEB-INF/web.xml
> 
> ... <context-param> <param-name>log4jConfigLocation</param-name> 
> <param-value>file:///opt/tomcat6/conf/myapp/log4j.xml</param-value>
>
>
> 
</context-param>
> ...
> 
> Pretty standard, works.
> 
> Question is, how can I make sure the Log4j configuration path is 
> not hard coded in the 'web.xml' at development time. Idea was:
> 
> webapps/myapp/META-INF/context.xml ... <Parameter 
> name="log4jConfigLocation" value="file://TBD" /> ...
> 
> and change it after the application deployment:
> 
> conf/Catalina/localhost/myapp.xml ... <Parameter 
> name="log4jConfigLocation" 
> value="file:///opt/tomcat6/conf/myapp/log4j.xml" /> ...
> 
> Tomcat simply ignores both of these context XML files, or at least 
> the parameters defined in them. I read through all mailing lists, 
> all documentations, switched on debug to the 'finest' level, still 
> no avail. How difficult can this be?
> 
> Details:
> 
> Server version: Apache Tomcat/6.0.35 Server built:   Nov 28 2011 
> 11:20:06 Server number:  6.0.35.0 OS Name:        Linux OS
> Version: 2.6.18-348.el5 Architecture:   amd64 JVM Version:
> 1.6.0_30-b12 JVM Vendor:     Sun Microsystems Inc.
> 
> 
> Cheers B.
> 

I'm just noodling - haven't tried this. Your mileage may vary, void
where prohibited, etc., etc., etc.

How about:

1. use Parameter in context.xml to set the logging level:

<Parameter name="LoggingLevel" value="DEBUG" override="false"/>

2. Write a servlet context listener to read the parameter

3. Set the logging level accordingly

Place the servlet context listener as the first one in your web.xml so
the new logging level is set before any other logging occurs.

This way your log4j.xml doesn't have to change, and you can just use
an appropriate $CATALINA_BASE/conf/Catalina/[hostname]/[appname].xml
to set the desired logging level.

This seems as if it should work.

. . . just my two cents
/mde/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (MingW32)

iQEcBAEBAgAGBQJUEHZvAAoJEEFGbsYNeTwte+YH/12yWANWhJ2+6MwCKHkdWh5G
AQi20L9LVdjTtWYx+vpZvktqiDSNvYAUTTx2+AJaolo9puqsaSLf5kfR1hTgbGy8
sMrBPLbJY1qY4uZruK5ISPc1I3nbo2j/uDtSpClbfMSGKLUIqcISiCxYwwcb/u5f
UUGXSorSddwCEE2i5Sk8wHpYMcEjRDXa99t6qR5I4Xe6Tb9KG8rJ9yfiB1//snwO
bOGmroKgYRB1sz7cM2xffZNW+3GzN/Z8py0GqdR07+sEDMTYpvVcW0Iu1ebmUtU6
Aw2QTcK9pu4kU+Q2DA7vOycXTdG/8XgFOnQCvhXWRvy63iR1pXiz6KNCZ6qBkrk=
=nU9F
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to