You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nishant Chandra <ni...@gmail.com> on 2009/09/22 10:42:01 UTC

Log4j

Hi,

I want to use Log4j and log from different web apps to one directory -
tomcat_home/output/logs/{webapp_context}_service.log

What should be the configuration in log4j.properties?
I am currently using
log4j.appender.xml.file=${catalina.base}/output/logs/service.log

What I want is to append app_context in the file name.

Thanks,
Nishant

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


Re: Log4j

Posted by Nishant Chandra <ni...@gmail.com>.
Thanks. This should work. I hope there was better logging
infrastructure in terms of compressing the file, ftp, log service,
archival etc.

Nishant

On Tue, Sep 22, 2009 at 8:35 PM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Jeffrey,
>
> On 9/22/2009 11:00 AM, Jeffrey Janner wrote:
>> My solution was to put log4j.jar in WEB-INF/lib of each instance, along
>> with individual log4j.properties files and setting different file paths
>> in the properties files.  Only solution I could find.
>
> I believe this is the best solution to this problem. It allows the
> webapp to have control over its own logging, which is nice. You can
> package a log4j.properties file along with your webapp and configure it
> however you like.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkq4558ACgkQ9CaO5/Lv0PDwdACgkBeSmO2gU+YFXrgKNL/P4/0I
> VxMAniVkA4PKQPNaXhXxuy4ViK7gJ/mo
> =CC3S
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>



-- 
Nishant Chandra
Hyderabad, India
Cell : +91 9949828480

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


Re: Log4j

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeffrey,

On 9/22/2009 11:00 AM, Jeffrey Janner wrote:
> My solution was to put log4j.jar in WEB-INF/lib of each instance, along
> with individual log4j.properties files and setting different file paths
> in the properties files.  Only solution I could find.

I believe this is the best solution to this problem. It allows the
webapp to have control over its own logging, which is nice. You can
package a log4j.properties file along with your webapp and configure it
however you like.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkq4558ACgkQ9CaO5/Lv0PDwdACgkBeSmO2gU+YFXrgKNL/P4/0I
VxMAniVkA4PKQPNaXhXxuy4ViK7gJ/mo
=CC3S
-----END PGP SIGNATURE-----

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


RE: Log4j

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
I had a similar problem with log4j.
We host our webapp for various customers, an instance (host) per
customer, therefore the same code for each customer.  I tried sharing
log4j.jar in shared/lib, but found all customer loading into the same
log file - very confusing.
My solution was to put log4j.jar in WEB-INF/lib of each instance, along
with individual log4j.properties files and setting different file paths
in the properties files.  Only solution I could find.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, September 22, 2009 6:02 AM
To: Tomcat Users List
Subject: Re: Log4j

2009/9/22 Nishant Chandra <ni...@gmail.com>:
> I want to use Log4j and log from different web apps to one directory -
> tomcat_home/output/logs/{webapp_context}_service.log
>
> What should be the configuration in log4j.properties?
> I am currently using
> log4j.appender.xml.file=${catalina.base}/output/logs/service.log
>
> What I want is to append app_context in the file name.

IIRC, there is no way to obtain the application context path as an
environment variable.
You should configure Log4j using its APIs, using a
ServletContextListener.
Probably the best way is to load the "log4j.properties" file and
modify only the property that refers to the path of the file, then
configure Log4j.

Antonio

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



*******************************  NOTICE  *********************************
This message is intended for the use of the individual or entity to which 
it is addressed and may contain information that is privileged, 
confidential, and exempt from disclosure under applicable law.  If the 
reader of this message is not the intended recipient or the employee or 
agent responsible for delivering this message to the intended recipient, 
you are hereby notified that any dissemination, distribution, or copying 
of this communication is strictly prohibited.  If you have received this 
communication in error, please notify us immediately by reply or by 
telephone (call us collect at 512-343-9100) and immediately delete this 
message and all its attachments.


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


Re: Log4j

Posted by Antonio Petrelli <an...@gmail.com>.
2009/9/22 Nishant Chandra <ni...@gmail.com>:
> I want to use Log4j and log from different web apps to one directory -
> tomcat_home/output/logs/{webapp_context}_service.log
>
> What should be the configuration in log4j.properties?
> I am currently using
> log4j.appender.xml.file=${catalina.base}/output/logs/service.log
>
> What I want is to append app_context in the file name.

IIRC, there is no way to obtain the application context path as an
environment variable.
You should configure Log4j using its APIs, using a ServletContextListener.
Probably the best way is to load the "log4j.properties" file and
modify only the property that refers to the path of the file, then
configure Log4j.

Antonio

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