You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Olexandr Prokhorenko <ol...@prokhorenko.us> on 2009/04/10 22:30:58 UTC

log4j logging to stdout and server-wide override

Hi,

I have an application-wide log4j.properties which logs to stdout, with  
the config like:

log4j.rootLogger=WARN, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

It sends all mess to catalina.out.  However, I want to use log4j for  
Tomcat 5.5 logging now.  So I configured Tomcat to write WARN to  
tomcat.log and eventually I'll want to receive ERROR by email  
(org.apache.log4j.net.SMTPAppender or just different file work work  
just fine for me).  Here's what I've got for conf/log4j.properties (or  
common/classes/log4j.properties, as I basically have a symlink).

log4j.rootLogger=WARN, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

log4j.logger.org.apache.catalina.core=WARN, R
log4j.logger.org.apache.catalina.session=WARN, R

However, it comes that because of my application(s) write directly to  
stdout they don't happen to appear in my server-wide log4j output,  
their messages still go to catalina.out.  I changed conf/context.xml  
to include swallowOutput, but it doesn't seem to be working (at least  
not for my stuff):

<Context swallowOutput="true" />

My application(s) still write to catalina.out.  What is the best way  
to make it do what I want?  Thank you.

P.S. I have more then 20 wars built with log4j.properties which write  
to stdout, so changing this piece is pretty unwelcome. ;)  I'd be  
happy to find some server-wide override tool instead.  Sometimes I  
don't even know does the application have an explicit stdout output or  
not.  Thank you.

--Alexander Prohorenko.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: log4j logging to stdout and server-wide override

Posted by Olexandr Prokhorenko <ol...@prokhorenko.us>.
Jake,

Actually, I'm working on quite different thing.  I have applications  
deployed that are logging through log4j to stdout:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

and it goes into catalina.out (which actually the redirect of Tomcat's  
stdout).

I want to stop it messing to stdout, and pass it to log4j.  I thought  
that is what swallowOutput for, but it looks like it doesn't work the  
way I need it to.

Thanks.

--Alexander Prohorenko.

On Apr 10, 2009, at 9:03 PM, Jacob Kjome wrote:

> I'm not sure if this will help, but I run Tomcat6 under on Windows  
> and use the
> Tomcat Service.  The service redirects stdout and stderr to files.   
> For log4j, I
> simply define a ConsoleAppender and assign it to the root logger,  
> which gets
> directed to the stdout log file.  stdout goes to stdout_[current  
> date].log and
> stderr goes to stderr_[current date].log without me specifying those  
> log file
> names.  System.out goes to the stdout log file.
>
> Not sure what the equivalent setup would be on a *nix box, but I'm  
> sure there's
> something similar.
>
>
> Jake
>
> On 4/10/2009 2:30 PM, Olexandr Prokhorenko wrote:
>> Hi,
>>
>> I have an application-wide log4j.properties which logs to stdout,  
>> with
>> the config like:
>>
>> log4j.rootLogger=WARN, stdout
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>>
>> It sends all mess to catalina.out.  However, I want to use log4j for
>> Tomcat 5.5 logging now.  So I configured Tomcat to write WARN to
>> tomcat.log and eventually I'll want to receive ERROR by email
>> (org.apache.log4j.net.SMTPAppender or just different file work work  
>> just
>> fine for me).  Here's what I've got for conf/log4j.properties (or
>> common/classes/log4j.properties, as I basically have a symlink).
>>
>> log4j.rootLogger=WARN, R
>> log4j.appender.R=org.apache.log4j.RollingFileAppender
>> log4j.appender.R.File=${catalina.home}/logs/tomcat.log
>> log4j.appender.R.MaxFileSize=10MB
>> log4j.appender.R.MaxBackupIndex=5
>> log4j.appender.R.layout=org.apache.log4j.PatternLayout
>> log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
>>
>> log4j.logger.org.apache.catalina.core=WARN, R
>> log4j.logger.org.apache.catalina.session=WARN, R
>>
>> However, it comes that because of my application(s) write directly to
>> stdout they don't happen to appear in my server-wide log4j output,  
>> their
>> messages still go to catalina.out.  I changed conf/context.xml to
>> include swallowOutput, but it doesn't seem to be working (at least  
>> not
>> for my stuff):
>>
>> <Context swallowOutput="true" />
>>
>> My application(s) still write to catalina.out.  What is the best  
>> way to
>> make it do what I want?  Thank you.
>>
>> P.S. I have more then 20 wars built with log4j.properties which  
>> write to
>> stdout, so changing this piece is pretty unwelcome. ;)  I'd be  
>> happy to
>> find some server-wide override tool instead.  Sometimes I don't even
>> know does the application have an explicit stdout output or not.   
>> Thank
>> you.
>>
>> --Alexander Prohorenko.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: log4j logging to stdout and server-wide override

Posted by Jacob Kjome <ho...@visi.com>.
I'm not sure if this will help, but I run Tomcat6 under on Windows and use the
Tomcat Service.  The service redirects stdout and stderr to files.  For log4j, I
simply define a ConsoleAppender and assign it to the root logger, which gets
directed to the stdout log file.  stdout goes to stdout_[current date].log and
stderr goes to stderr_[current date].log without me specifying those log file
names.  System.out goes to the stdout log file.

Not sure what the equivalent setup would be on a *nix box, but I'm sure there's
something similar.


Jake

On 4/10/2009 2:30 PM, Olexandr Prokhorenko wrote:
> Hi,
> 
> I have an application-wide log4j.properties which logs to stdout, with
> the config like:
> 
> log4j.rootLogger=WARN, stdout
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> 
> It sends all mess to catalina.out.  However, I want to use log4j for
> Tomcat 5.5 logging now.  So I configured Tomcat to write WARN to
> tomcat.log and eventually I'll want to receive ERROR by email
> (org.apache.log4j.net.SMTPAppender or just different file work work just
> fine for me).  Here's what I've got for conf/log4j.properties (or
> common/classes/log4j.properties, as I basically have a symlink).
> 
> log4j.rootLogger=WARN, R
> log4j.appender.R=org.apache.log4j.RollingFileAppender
> log4j.appender.R.File=${catalina.home}/logs/tomcat.log
> log4j.appender.R.MaxFileSize=10MB
> log4j.appender.R.MaxBackupIndex=5
> log4j.appender.R.layout=org.apache.log4j.PatternLayout
> log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
> 
> log4j.logger.org.apache.catalina.core=WARN, R
> log4j.logger.org.apache.catalina.session=WARN, R
> 
> However, it comes that because of my application(s) write directly to
> stdout they don't happen to appear in my server-wide log4j output, their
> messages still go to catalina.out.  I changed conf/context.xml to
> include swallowOutput, but it doesn't seem to be working (at least not
> for my stuff):
> 
> <Context swallowOutput="true" />
> 
> My application(s) still write to catalina.out.  What is the best way to
> make it do what I want?  Thank you.
> 
> P.S. I have more then 20 wars built with log4j.properties which write to
> stdout, so changing this piece is pretty unwelcome. ;)  I'd be happy to
> find some server-wide override tool instead.  Sometimes I don't even
> know does the application have an explicit stdout output or not.  Thank
> you.
> 
> --Alexander Prohorenko.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org