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 Mayer István János <ma...@t-email.hu> on 2009/02/07 19:40:05 UTC

split log into different files by level

Hi,

I use log4J 1.3 (becouse the application will run under os4690 and there are java 1.4)
I tried to split the logs into different files by level. The result was strange all the .log contain all the log lines.

My config files was this:


log4j.rootLogger=ALL, Timer, ErrorReport, InfoReport

#################
#  Timer
#################
log4j.appender.Timer=org.apache.log4j.DailyRollingFileAppender
log4j.appender.Timer.file=C:/AMROFILER/Report/Timer.log
log4j.appender.Timer.file.DatePattern='.'yyyyMMdd
log4j.appender.Timer.Append=true
log4j.appender.Timer.file.MaxBackupIndex=10
log4j.appender.Timer.layout=org.apache.log4j.PatternLayout
log4j.appender.Timer.layout.ConversionPattern=%-5p [%10t] %d{yyyy.MM.dd HH:mm:ss,SSS} %-20.20c %m%n

#################
#  Error Report
#################
log4j.appender.ErrorReport=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ErrorReport.file.DatePattern='.'yyyyMMdd
log4j.appender.ErrorReport.file=C:/AMROFILER/Report/Error.log
log4j.appender.ErrorReport.file.MaxBackupIndex=10
log4j.appender.ErrorReport.Append=true
log4j.appender.ErrorReport.file.Threshold=ERROR
log4j.appender.ErrorReport.layout=org.apache.log4j.PatternLayout
log4j.appender.ErrorReport.layout.ConversionPattern=%-5p [%10t] %d{MM.dd HH:mm:ss} %m%n

#################
#  Info Report
#################
log4j.appender.InfoReport.file.Threshold=INFO
log4j.appender.InfoReport=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoReport.file.DatePattern='.'yyyyMMdd
log4j.appender.InfoReport.file=C:/AMROFILER/Report/Info.log
log4j.appender.InfoReport.Append=true
log4j.appender.InfoReport.file.MaxBackupIndex=10
log4j.appender.InfoReport.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoReport.layout.ConversionPattern=%-5p [%10t] %d{MM.dd HH:mm:ss} %m%n

What is wrong inside?

Thanks,
Istvan

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


Va: Re: split log into different files by level

Posted by Mayer István János <ma...@t-email.hu>.
Thanks,

I changed the version to 1.2 and the logger works as i wanted.
Thank You

Feladó: Curt Arnold <ca...@apache.org>
Dátum: Vasárnap, 2009.02.08 de. 5:33
Tárgy: Re: split log into different files by level
Címzett: Log4J Users List <lo...@logging.apache.org>

> 
> On Feb 7, 2009, at 12:40 PM, Mayer István János wrote:
> 
> > Hi,
> >
> > I use log4J 1.3 (becouse the application will run under os4690 
> and  
> > there are java 1.4)
> 
> log4j 1.3 is a dead branch.  Several features from log4j 1.3 have 
> been  
> back-ported to work with log4j 1.2.  You can use it if you want, 
> but  
> there is no anticipated further development and limited support  
> available.
> 
> >
> > I tried to split the logs into different files by level. The 
> result  
> > was strange all the .log contain all the log lines.
> >
> > My config files was this:
> >
> >
> > log4j.rootLogger=ALL, Timer, ErrorReport, InfoReport
> >
> > #################
> > #  Timer
> > #################
> > log4j.appender.Timer=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.Timer.file=C:/AMROFILER/Report/Timer.log
> > log4j.appender.Timer.file.DatePattern='.'yyyyMMdd
> > log4j.appender.Timer.Append=true
> > log4j.appender.Timer.file.MaxBackupIndex=10
> > log4j.appender.Timer.layout=org.apache.log4j.PatternLayout
> > log4j.appender.Timer.layout.ConversionPattern=%-5p [%10t]  
> > %d{yyyy.MM.dd HH:mm:ss,SSS} %-20.20c %m%n
> >
> > #################
> > #  Error Report
> > #################
> > log4j.appender.ErrorReport=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.ErrorReport.file.DatePattern='.'yyyyMMdd
> > log4j.appender.ErrorReport.file=C:/AMROFILER/Report/Error.log
> > log4j.appender.ErrorReport.file.MaxBackupIndex=10
> > log4j.appender.ErrorReport.Append=true
> > log4j.appender.ErrorReport.file.Threshold=ERROR
> > log4j.appender.ErrorReport.layout=org.apache.log4j.PatternLayout
> > log4j.appender.ErrorReport.layout.ConversionPattern=%-5p [%10t]  
> > %d{MM.dd HH:mm:ss} %m%n
> >
> > #################
> > #  Info Report
> > #################
> > log4j.appender.InfoReport.file.Threshold=INFO
> > log4j.appender.InfoReport=org.apache.log4j.DailyRollingFileAppender
> > log4j.appender.InfoReport.file.DatePattern='.'yyyyMMdd
> > log4j.appender.InfoReport.file=C:/AMROFILER/Report/Info.log
> > log4j.appender.InfoReport.Append=true
> > log4j.appender.InfoReport.file.MaxBackupIndex=10
> > log4j.appender.InfoReport.layout=org.apache.log4j.PatternLayout
> > log4j.appender.InfoReport.layout.ConversionPattern=%-5p [%10t]  
> > %d{MM.dd HH:mm:ss} %m%n
> >
> > What is wrong inside?
> 
> You have a stray "file." in your Threshold and DatePattern property 
> 
> names.  The threshold is a lower bound, so if you correct the 
> property  
> names, you will have info and error messages in the Info report.  
> If  
> you really want to isolate each level in a different file, then you 
> 
> can use the LevelMatchFIlter.


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


Re: split log into different files by level

Posted by Curt Arnold <ca...@apache.org>.
On Feb 7, 2009, at 12:40 PM, Mayer István János wrote:

> Hi,
>
> I use log4J 1.3 (becouse the application will run under os4690 and  
> there are java 1.4)

log4j 1.3 is a dead branch.  Several features from log4j 1.3 have been  
back-ported to work with log4j 1.2.  You can use it if you want, but  
there is no anticipated further development and limited support  
available.

>
> I tried to split the logs into different files by level. The result  
> was strange all the .log contain all the log lines.
>
> My config files was this:
>
>
> log4j.rootLogger=ALL, Timer, ErrorReport, InfoReport
>
> #################
> #  Timer
> #################
> log4j.appender.Timer=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.Timer.file=C:/AMROFILER/Report/Timer.log
> log4j.appender.Timer.file.DatePattern='.'yyyyMMdd
> log4j.appender.Timer.Append=true
> log4j.appender.Timer.file.MaxBackupIndex=10
> log4j.appender.Timer.layout=org.apache.log4j.PatternLayout
> log4j.appender.Timer.layout.ConversionPattern=%-5p [%10t]  
> %d{yyyy.MM.dd HH:mm:ss,SSS} %-20.20c %m%n
>
> #################
> #  Error Report
> #################
> log4j.appender.ErrorReport=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.ErrorReport.file.DatePattern='.'yyyyMMdd
> log4j.appender.ErrorReport.file=C:/AMROFILER/Report/Error.log
> log4j.appender.ErrorReport.file.MaxBackupIndex=10
> log4j.appender.ErrorReport.Append=true
> log4j.appender.ErrorReport.file.Threshold=ERROR
> log4j.appender.ErrorReport.layout=org.apache.log4j.PatternLayout
> log4j.appender.ErrorReport.layout.ConversionPattern=%-5p [%10t]  
> %d{MM.dd HH:mm:ss} %m%n
>
> #################
> #  Info Report
> #################
> log4j.appender.InfoReport.file.Threshold=INFO
> log4j.appender.InfoReport=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.InfoReport.file.DatePattern='.'yyyyMMdd
> log4j.appender.InfoReport.file=C:/AMROFILER/Report/Info.log
> log4j.appender.InfoReport.Append=true
> log4j.appender.InfoReport.file.MaxBackupIndex=10
> log4j.appender.InfoReport.layout=org.apache.log4j.PatternLayout
> log4j.appender.InfoReport.layout.ConversionPattern=%-5p [%10t]  
> %d{MM.dd HH:mm:ss} %m%n
>
> What is wrong inside?

You have a stray "file." in your Threshold and DatePattern property  
names.  The threshold is a lower bound, so if you correct the property  
names, you will have info and error messages in the Info report.  If  
you really want to isolate each level in a different file, then you  
can use the LevelMatchFIlter.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org