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: How to trigger email eventough there is no ERROR
Date Fri, 10 Oct 2008 05:48:27 GMT

On Oct 9, 2008, at 7:42 PM, geek.shrek wrote:

> Hi,
>
> I'm using log4j 1.2  with java 1.4.2
>
> my log4j.properties
> log4j.rootCategory=DEBUG, mail
> log4j.rootCategory.debug=true
>
> log4j.appender.mail=org.apache.log4j.net.SMTPAppender
> log4j.appender.mail.EvaluatorClass=com.test.myEvaluator
> log4j.appender.mail.threshold=WARN
> log4j.appender.mail.SMTPHost=myhost.com
> log4j.appender.mail.To=test@myhost.com
> log4j.appender.mail.From=test@myhost.com
> log4j.appender.mail.Subject=Reporting
> log4j.appender.mail.layout=org.apache.log4j.PatternLayout
> log4j.appender.mail.layout.ConversionPattern=%d %p [%c] - %m %n
> log4j.appender.mail.SMTPDebug=true
>
> I also tried to create my own appender which extends SMTPAppender
> and overide activateOptions and add   
> LogManager.getLoggerRepository().setThreshold(Level.WARN);
>
> I still need to have an ERROR to be able to send email.
>
> I'm trying to build the log4j that you just updated in the  
> repository .. Thanks for that :) , but I'm still struggling to build  
> it with maven since I'm not so familiar with maven. But it seems  
> like exactly what I need for my application.
>
>
> Thanks,
>

Are you trying to build on a JDK 1.4?  If so, you need to uncomment  
the section in pom.xml around line 440 and download and install Sun's  
JMX reference implementation.  Probably easier just to build a jar  
with a later JDK, will still run on JDK 1.4.

If you still can't build, you could download a nightly from http://vmgump.apache.org/gump/public-jars/log4j/jars/

In your configuration file:

log4j.rootCategory.debug=true


is meaningless as far as I know.  Should have been just  
log4j.debug=true.

> log4j.appender.mail.threshold=WARN

results in all logging requests lower than WARN being discarded.  It  
has no effect on when an email is sent.

The extras companion in SVN has a FilterBasedTriggeringPolicy that  
could be configured with an XML configuration file to trigger on a  
lower level than ERROR.  See https://issues.apache.org/bugzilla/show_bug.cgi?id=32572

Configuration would look like:

   <appender name="A1" class="org.apache.log4j.net.SMTPAppender">

     <param name="from"   value="log4j@example.org" />
     <param name="to" value="somebody@example.org" />
     <param name="subject" value="Test message" />
     <param name="SMTPHost" value="localhost"/>
     <param name="sendOnClose" value="true"/>
     <triggeringPolicy  
class="org.apache.log4j.rolling.FilterBasedTriggeringPolicy">
		<filter class="org.apache.log4j.filter.LevelRangeFilter">
                   <param name="levelMin" value="info" />
		</filter>
     </triggeringPolicy>

     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%-5p %c{2} - %m%n"/>
     </layout>
   </appender>




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