logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: NewBie Help: How to select a ConversionPattern for a Logger I want
Date Wed, 28 Nov 2007 01:06:09 GMT

On Nov 27, 2007, at 5:28 PM, enthucoder wrote:

>
> Hi everybody,
>
> Here is my log4j.properties file:
>
> log4j.rootLogger=DEBUG,ROOT
> log4j.logger.org.apache.jsp.pages=INFO
>
> log4j.appender.ROOT=org.apache.log4j.RollingFileAppender
> log4j.appender.ROOT.File=myapplication.log
> log4j.appender.ROOT.MaxFileSize=1000KB
> log4j.appender.ROOT.MaxBackupIndex=9
> log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
> log4j.appender.ROOT.layout.ConversionPattern=[%d] CLASS: "%c" %-5p -  
> %m%n
>
> Now, I want to have sepecific type of ConversionPattern for the logger
> "org.apache.jsp.pages"
>
> How do i achieve this? Also, if there is some tutorial online which  
> provides
> this information would be great too.
>
> Thanks for the help in advance.
>
> .H


Layouts are associated with Appenders, not Loggers, since some  
appenders need a layout to convert a logging event to a character  
string and other appenders don't.  In general, you'd want a file to  
have a consistent pattern so consumers (like Chainsaw) can process the  
file based on an expected pattern.

Your options are:

Associate the logger "org.apache.jsp.pages" with another appender  
writing to a different destination with a different layout.  Set  
additivity=false on the logger if you don't want the messages to also  
appear in the appender associated with root.

If you really want to intermix different patterns in the same file,  
you'd need to write a custom layout that delegated to different  
PatternLayout's based on the logger name in the logging event.

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


Mime
View raw message