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 Benny Yu <bl...@hotmail.com> on 2002/03/25 22:01:15 UTC

Appenders

Hi,

    I am trying to figure out how to assign different log level to different 
appenders for the same Category.  I want to be able to log only ERROR level 
to console appender but at the same time log DEBUG in a file appender.  
Could someone point me to the right direction in accomplishing this.

Thanks in advance,
Benny

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Appenders

Posted by Hu <xw...@yahoo.com>.
Using Threshhold option the ERROR still goes to
Console, right? I would like to set up that in the
same category, INFO goes to one file, ERROR goes to
another file, so we can deal with the message
differently.

Also, I have another question about the configure. I
would like to log all the ERROR level msg in all our
classes into one error log, and if any class need more
infomation, that class can log into different log.
In my following set up, the classes that dosen't have
category, the ERROR msg is not written into the error
log. How can I do it?

#################################
	<appender name="infoLog"
class="org.apache.log4j.FileAppender">
            <param name="File"
value="'c:/infologs/infolog.log" />
            <param name="Append" value="true" />	
            <layout
class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d - %m%n"/>
            </layout>	    
	</appender>
	<appender name="errorLog"
class="org.apache.log4j.FileAppender">
            <param name="DatePattern"
value="'c:/errorlogs/errorlog.log" />
            <param name="Append" value="true" />
	    <param name="Threshold" value="ERROR" />	
            <layout
class="org.apache.log4j.PatternLayout">
		<param name="ConversionPattern" value="%d [%t]
(%F:%L) - %m%n"/>
            </layout>	    
	</appender>
	<appender name="email"
class="org.apache.log4j.SMTPAppender">
            	<param name="SMTPHost"
value="mail.mydomain.com" />
		<param name="From" value="app@mydomain.com" />
		<param name="To" value="me@mydomain.com" />
		<param name="Subject" value="[App Alert]" />
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern"
value="%d\t%p\t(%F:%L) %m%n"/>
		</layout>	    
	</appender>
	<appender name="STDOUT"
class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern"
		          value="%d %-5p [%t] (%F:%L) - %m%n"/>
		</layout>		
	</appender>

	<category name="com.mydomain.myclass"
additivity="false">
	  <priority value="info" />
  	  <appender-ref ref="infoLog" />
	</category>
	<category name="com.mydomain" additivity="false">
	  <priority value="error" />
  	  <appender-ref ref="errorLog" />
	  <appender-ref ref="email" />
	</category>	
	<root>
	   <priority value ="debug" />
   	   <appender-ref ref="STDOUT" />
	</root>

Thanks

--- Benny Yu <bl...@hotmail.com> wrote:
> Hi,
> 
>     I am trying to figure out how to assign
> different log level to different 
> appenders for the same Category.  I want to be able
> to log only ERROR level 
> to console appender but at the same time log DEBUG
> in a file appender.  
> Could someone point me to the right direction in
> accomplishing this.
> 
> Thanks in advance,
> Benny
> 
>
_________________________________________________________________
> Chat with friends online, try MSN Messenger:
> http://messenger.msn.com
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>