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 Joe Rice <jo...@mercurymd.com> on 2005/08/19 16:11:22 UTC

Do Not Log one Logger to Console

I have a log4j.properties file with a Console appender and a RollingFile
appender.  I have a specific Logger that I only want logged to the
RollingFile appender and not to the Console appender.  I thought I could
do this by explicity associating an appender with the Logger but that
doesn't seem to be working.  Can I do this if I have my Console appender
associated with the root logger?  Here's my log4j.properties.
 
log4j.rootLogger=ERROR, Console
 
# Console is set to be a ConsoleAppender.
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%-5p %c{2}.%M.%L - %m%n
 
#File Appender
log4j.appender.LogFile=org.apache.log4j.FileAppender
log4j.appender.LogFile.file=conf/translator.log
log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern=%-5p %c{2} - %m%n
 
# Logger that should only log to the file and NOT to the Console
log4j.logger.com.mycompany.SpecificLogger = DEBUG, LogFile
 
Any help would be appreciated.
 
Thanks,

Joe

Re: Do Not Log one Logger to Console

Posted by James Stauffer <st...@gmail.com>.
Set additivity to false for that logger and the messages won't make it
to the root logger.

On 8/19/05, Joe Rice <jo...@mercurymd.com> wrote:
> I have a log4j.properties file with a Console appender and a RollingFile
> appender.  I have a specific Logger that I only want logged to the
> RollingFile appender and not to the Console appender.  I thought I could
> do this by explicity associating an appender with the Logger but that
> doesn't seem to be working.  Can I do this if I have my Console appender
> associated with the root logger?  Here's my log4j.properties.
> 
> log4j.rootLogger=ERROR, Console
> 
> # Console is set to be a ConsoleAppender.
> log4j.appender.Console=org.apache.log4j.ConsoleAppender
> log4j.appender.Console.layout=org.apache.log4j.PatternLayout
> log4j.appender.Console.layout.ConversionPattern=%-5p %c{2}.%M.%L - %m%n
> 
> #File Appender
> log4j.appender.LogFile=org.apache.log4j.FileAppender
> log4j.appender.LogFile.file=conf/translator.log
> log4j.appender.LogFile.layout=org.apache.log4j.PatternLayout
> log4j.appender.LogFile.layout.ConversionPattern=%-5p %c{2} - %m%n
> 
> # Logger that should only log to the file and NOT to the Console
> log4j.logger.com.mycompany.SpecificLogger = DEBUG, LogFile
> 
> Any help would be appreciated.
> 
> Thanks,
> 
> Joe
> 
> 


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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