You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Perrone <ja...@blueskylogistics.com> on 2007/12/03 22:09:26 UTC

Split Tomcat standard out into files for each context in 5.5

Hello,

 

Please forgive me if this question was already answered.  I use log4j in
my application, but still you always have some log messages that end up
in stdout.  For these, and for all messages that end up in stdout, I
would like there to be a separate log file for each of the applications
(contexts) deployed in the container.  When trying to debug and looking
for log messages it can get quite convoluted when all of the contexts
are logging to the same file.

 

I appreciate the help. Thanks.

 

Jason 

 


RE: Split Tomcat standard out into files for each context in 5.5

Posted by Jason Perrone <ja...@blueskylogistics.com>.
Thanks Mark.


-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Tuesday, December 04, 2007 12:58 PM
To: Tomcat Users List
Subject: Re: Split Tomcat standard out into files for each context in 5.5

Christopher Schultz wrote:
> Mark,
> 
> Mark Thomas wrote:
>> Not strictly true.
> 
>> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> 
>> You want the swallowOutput parameter of the context.
> 
> Wow, I had never seen that. How does Tomcat subvert java.lang.System.out
> like that? I'm happy to read the code if you can provide a starting point.

Take a look at this class
http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
and its use of
http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java

There are a couple of other places where this takes place. Grepping for
SystemLogHandler should find them.

HTH,

Mark



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


Re: Split Tomcat standard out into files for each context in 5.5

Posted by Mark Thomas <ma...@apache.org>.
Christopher Schultz wrote:
> Mark,
> 
> Mark Thomas wrote:
>> Not strictly true.
> 
>> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> 
>> You want the swallowOutput parameter of the context.
> 
> Wow, I had never seen that. How does Tomcat subvert java.lang.System.out
> like that? I'm happy to read the code if you can provide a starting point.

Take a look at this class
http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
and its use of
http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java

There are a couple of other places where this takes place. Grepping for
SystemLogHandler should find them.

HTH,

Mark



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


Re: Split Tomcat standard out into files for each context in 5.5

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

Mark,

Mark Thomas wrote:
> Not strictly true.
> 
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
> 
> You want the swallowOutput parameter of the context.

Wow, I had never seen that. How does Tomcat subvert java.lang.System.out
like that? I'm happy to read the code if you can provide a starting point.

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

iD8DBQFHVWsP9CaO5/Lv0PARAsTiAJsH02Wp0ulj6HPLAEn1hmVEKtra2QCdFHAW
OruwLUGivHetnjTWdCD1c1s=
=1oGw
-----END PGP SIGNATURE-----

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


Re: Split Tomcat standard out into files for each context in 5.5

Posted by Mark Thomas <ma...@apache.org>.
Christopher Schultz wrote:
> Jason,
> 
> Jason Perrone wrote:
>> Please forgive me if this question was already answered.  I use log4j in
>> my application, but still you always have some log messages that end up
>> in stdout.  For these, and for all messages that end up in stdout, I
>> would like there to be a separate log file for each of the applications
>> (contexts) deployed in the container.  When trying to debug and looking
>> for log messages it can get quite convoluted when all of the contexts
>> are logging to the same file.
> 
> Sorry, dude. Stdout is stdout. If you call System.out.print and friends,
> it's gonna go to (the unified) standard output. There's no way to
> redirect stuff depending on the webapp that emitted the output.

Not strictly true.

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

You want the swallowOutput parameter of the context.

Mark


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


Re: Split Tomcat standard out into files for each context in 5.5

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

Jason,

Jason Perrone wrote:
> Please forgive me if this question was already answered.  I use log4j in
> my application, but still you always have some log messages that end up
> in stdout.  For these, and for all messages that end up in stdout, I
> would like there to be a separate log file for each of the applications
> (contexts) deployed in the container.  When trying to debug and looking
> for log messages it can get quite convoluted when all of the contexts
> are logging to the same file.

Sorry, dude. Stdout is stdout. If you call System.out.print and friends,
it's gonna go to (the unified) standard output. There's no way to
redirect stuff depending on the webapp that emitted the output.

If you were to embed Tomcat, you might be able to set System.out to
something other than a standard PrintWriter pointing to the console, and
roll your own hacked-up logging facility, but I would recommend against
all that.

By now, I think all the logging in Tomcat goes through the logger,
rather than directly to standard out. You ought to be able to set up
conf/logging.properties and friends to do things differently. You can
certainly set up a <Logger> element in your context.xml, though that is
likely to result in an application-specific log file as well as the same
output going to your stdout. You can always direct the logger to ignore
log messages from classes like com.yourcompany.*.

- -chris

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

iD8DBQFHVHZ49CaO5/Lv0PARAnziAKC1sOtSiC/VDxfeh/3KGbVEeVBr8ACeMaua
4HvtLGuSztgQjKMZPFOjMFs=
=3/Kl
-----END PGP SIGNATURE-----

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