logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Girish Bapat" <Girish_Ba...@kaleconsultants.com>
Subject RE: Log4j Messages into different files based on diffent Levels
Date Wed, 21 Dec 2005 10:24:04 GMT
Hello Krishna,

Thanks for your information regarding configuration.
I want similar functionality; I dont want any other level messeges to get percolated in my
debug file other than debug level

I have done following configurations in my log4j.properties file they are as follows:

log4j.rootCategory=DEBUG, Console, DebugFile, InfoFile, ErrorFile, FatalFile

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%d{dd/MM/yyyy HH:mm:ss.SSS}] [%-5p Msg -
%c %M %L] %m%n
log4j.appender.Console.Threshold=DEBUG

# Appender DebugFile outputs to the debug log file
log4j.appender.DebugFile=com.kaleconsultants.commons.RollingFileAppender
log4j.appender.DebugFile.File=..\\..\\logs\\debug
log4j.appender.DebugFile.MaxFileSize=5MB
log4j.appender.DebugFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugFile.layout.ConversionPattern=[%d{dd/MM/yyyy HH:mm:ss.SSS}] [%-5p Msg
- %c %M %L] %m%n
log4j.appender.DebugFile.Threshold=DEBUG
log4j.appender.DebugFile.BufferedIO=false

log4j.appender.DebugFile.filter=org.apache.log4j.varia.LevelMatchFilter
log4j.appender.DebugFile.filter.LevelToMatch=debug
log4j.appender.DebugFile.filter.AcceptOnMatch=true
log4j.appender.DebugFile.filter=org.apache.log4j.varia.DenyAllFilter

Please note that I have added above four entries as from your mail.
But I am getting following error.
log4j:WARN Failed to set property [filter] to value "org.apache.log4j.varia.DenyAllFilter".

Please help me for the same.
-

Thanks in advance,
Girish




> ----------
> From: 	krishna kumar[SMTP:krish_indus@yahoo.com]
> Reply To: 	Log4J Users List
> Sent: 	Wednesday, December 21, 2005 11:46 AM
> To: 	Log4J Users List
> Subject: 	Re: Log4j Messages into different files based on diffent Levels
> 
> Hi,
> 
>   Try with this XML Configuration...and let us know
> whetehr it works for u or not.
> 
> Here it is:::::;;
> 
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration>
> <appender name="debugOnly"
> class="org.apache.log4j.RollingFileAppender">
>         <param name="File" value="Audit.log"/>
>         <param name="MaxFileSize" value="10MB"/>
>         <param name="MaxBackupIndex" value="1"/>
> 	    <param name="Append" value="true"	/>
> 	    <layout  class="org.apache.log4j.PatternLayout">
>             <param name="ConversionPattern"  value="%d
> %-5p %-17c{2} (%30F:%L) %3x - %m%n"/>
>         </layout>
>         <!--Filter to log debug messages only-->
> 		<filter
> class="org.apache.log4j.varia.LevelMatchFilter" >
> 		   <param name="LevelToMatch" value="debug"/>
> 		   <param name="AcceptOnMatch" value="true"/>
> 		</filter>						 
> 		
> 	    <filter
> class="org.apache.log4j.varia.DenyAllFilter"/>
> </appender>
> 
> <appender name="errorOnly"
> class="org.apache.log4j.RollingFileAppender">
>          <param name="File" value="Error.log"/>
> 		 <param name="MaxFileSize" value="10KB"/>
>          <param name="MaxBackupIndex" value="1"/>
>          <layout 
> class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern"  value="%d
> %-5p %-17c{2} (%30F:%L) %3x - %m%n"/>
>         </layout>
> 
> 		<!--Filter to log error messages only-->
>         <filter
> class="org.apache.log4j.varia.LevelMatchFilter" >
>            <param name="LevelToMatch" value="error"/>
>            <param name="AcceptOnMatch" value="true"/>
>         </filter>
>        <filter
> class="org.apache.log4j.varia.DenyAllFilter"/>
> 													  
> </appender>
> 
> <logger name ="MyLogger" aditivity="false">
> 	  <level value="debug"/>	
> 	  <appender-ref ref="debugOnly"/>
> 	  <appender-ref ref="errorOnly"/>
> </logger>
> 
> 
> <root>
>   <level value="debug"/>
>   <appender-ref ref="debugOnly"/>
> </root>
> 
> </log4j:configuration>> 
> 
> 
> Regards,
> Krish
> 
> 
> 
> 
> --- James Stauffer <stauffer.james@gmail.com> wrote:
> 
> > You can setup 5 appenders on the root logger and
> > then use a
> > LevelMatchFilter on each appender to get only one
> > level.
> > 
> > I find that it is useful to have appenders that
> > include a level and
> > all higher levels.
> > i.e. Debug appender will have all logs, info will
> > have info and higher, etc.
> > To do that just set a threshold on each appender.
> > info would have a
> > threshold of info, warn would have a threshold of
> > warn, etc.
> > This has the advantage of being able to look at the
> > debug lines around an error.
> > 
> > On 12/20/05, Philip Denno <pdenno@tsi.bc.ca> wrote:
> > > Are you are asking how to send different level
> > messages to different
> > > files using one logger?
> > >
> > > If this is the case then I think the answer is
> > that it is not possible.
> > >
> > > If you really need to separate the level messages
> > then you would need to
> > > use different loggers for each level.
> > >
> > > Can I ask what the rational behind this separation
> > is? If you want to be
> > > able to locate errors quickly you should consider
> > using some filtering
> > > tool such as Chainsaw, or if errors need to be
> > handled quickly, try
> > > configuring an SMTPAppender to ERROR.
> > >
> > > Cheers,
> > > Philip.
> > >
> > > -----Original Message-----
> > > From: Sravan Duggaraju [mailto:saaan.di@gmail.com]
> > > Sent: December 20, 2005 1:52 PM
> > > To: log4j-user@logging.apache.org
> > > Subject: Re: Log4j Messages into different files
> > based on diffent Levels
> > >
> > >
> > >  I have gone through the document and tried to
> > implement it...but the
> > > messages are showing in all files.
> > >
> > > My requrement is  information related messages
> > should go to AuditLog and
> > > Error messages should go to ErrorLog.
> > >
> > > i was setting the messages like
> > >  logger.info("this is info message");
> > > logger.error("this is error message");
> > >
> > >
> > >
> > >
> > > On 12/20/05, Sravan Duggaraju <saaan.di@gmail.com>
> > wrote:
> > > >
> > > > Hi,
> > > > Using log4j  can we log different level msgs
> > (like DEBUG,ERROR,INFO
> > > > etc) in separate file appenders? For example,
> > all the 'INFO' messages
> > > > go to AuditLog. 'ERROR' messages would go to
> > ErrorLog ..
> > > > Please let me know if any option is avaialble to
> > perform this.
> > > >
> > > > I appreciate if you can send the properties/xml
> > file and how you
> > > > accessed it form the application.
> > > >
> > > > Thanks
> > > > Sandi
> > > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > log4j-user-unsubscribe@logging.apache.org
> > > For additional commands, e-mail:
> > log4j-user-help@logging.apache.org
> > >
> > >
> > 
> > 
> > --
> > 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
> > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 

Disclaimer:
This e-mail may contain Privileged/Confidential information and is 
intended only for the individual(s) named. Please notify the sender, if 
you have received this e-mail by mistake and delete it from your system. 
Information in this message that do not relate to the official business of 
the company shall be understood as neither given nor endorsed by it. 
E-mail transmission cannot be guaranteed to be secure or error-free. The 
sender does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission. 
If verification is required please request a hard-copy version.
Visit us at www.kaleconsultants.com

---------------------------------------------------------------------
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