logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "None None" <japp...@hotmail.com>
Subject RE: SMTPAppender only for ERROR and FATAL?
Date Fri, 08 Oct 2004 20:49:12 GMT
OK thanks I got! It's not that obvious! BUt I get an exception....

package somepackagename

// My custom level.
public class XLevel extends Level
{
	static public final int MANAGEMENT_INT = Level.FATAL_INT + 1;
	private static String MANAGEMENT_STR = "MANAGEMENT";
	public static final XLevel MANAGEMENT = new XLevel(MANAGEMENT_INT, 
MANAGEMENT_STR, 0);

	protected XLevel(int level, String strLevel, int syslogEquiv)
	{
		super(level, strLevel, syslogEquiv);
	}
}

// Evaluator class taken from SMTPAeppnder source code and renamed.
class XEvaluator implements TriggeringEventEvaluator
{
	public boolean isTriggeringEvent(LoggingEvent event)
	{
		// Check against custom Level
		return event.level.isGreaterOrEqual(XLevel.MANAGEMENT);
	}
}

In my xml config
<param name="EvaluatorClass" value="somepackagename.XEvaluator"/>

log4j:ERROR Could not instantiate class [somepackagename.XEvaluator].
java.lang.IllegalAccessException: Class 
org.apache.log4j.helpers.OptionConverter can not access a member of class 
somepackagename.XEvaluator with modifiers ""
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
	at java.lang.Class.newInstance0(Class.java:302)
	at java.lang.Class.newInstance(Class.java:261)
	at 
org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:319)
	at org.apache.log4j.net.SMTPAppender.setEvaluatorClass(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at 
org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:196)
	at 
org.apache.log4j.config.PropertySetter.setProperty(PropertySetter.java:155)
	at 
org.apache.log4j.xml.DOMConfigurator.setParameter(DOMConfigurator.java:530)
	at 
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:182)
	at 
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:140)
	at 
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:153)
	at 
org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:415)
	at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:384)
	at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:783)
	at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:666)
	at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:616)
	at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:584)
	at org.apache.log4j.xml.XMLWatchdog.doOnChange(DOMConfigurator.java:815)
	at 
org.apache.log4j.helpers.FileWatchdog.checkAndConfigure(FileWatchdog.java:80)
	at org.apache.log4j.helpers.FileWatchdog.<init>(FileWatchdog.java:49)
	at org.apache.log4j.xml.XMLWatchdog.<init>(DOMConfigurator.java:807)
	at 
org.apache.log4j.xml.DOMConfigurator.configureAndWatch(DOMConfigurator.java:574)
	at tmi.Daemon.main(Daemon.java:37)

Thanks

>From: "Scott Deboy" <sdeboy@comotivsystems.com>
>Reply-To: "Log4J Users List" <log4j-user@logging.apache.org>
>To: "Log4J Users List" <log4j-user@logging.apache.org>
>Subject: RE: SMTPAppender only for ERROR and FATAL?
>Date: Fri, 8 Oct 2004 13:23:40 -0700
>
>You write the evaluator yourself, include it in your classpath and specify 
>it in the config file.
>
>Click on the link to TriggeringEventEvaluator in the SMTPAppender javadoc - 
>that will explain.
>
>OK, here's the link: 
>http://logging.apache.org/log4j/docs/api/org/apache/log4j/spi/TriggeringEventEvaluator.html
>
>Your evaluator is called each time an event is processed by the appender to 
>see if the event will trigger the send of the email.
>
>The body of your TriggeringEventEvaluator could have:
>
>return true;
>
>to have SMTPAppender send an email with every event evaluated by the 
>evaluator.
>
>
>-----Original Message-----
>From:	None None [mailto:jappdev@hotmail.com]
>Sent:	Fri 10/8/2004 1:00 PM
>To:	log4j-user@logging.apache.org
>Cc:
>Subject:	RE: SMTPAppender only for ERROR and FATAL?
>Sorry I dont want to be stupid and I dont want to get RTFM
>
>It's the first time I use log4j what class is this? Where do I get this
>evaluator class name? And what does it have to do with the fact that SMTP
>appender only sends if the level is ERROR or FATAL?
>
>Thanks
>
>
> >From: "Scott Deboy" <sdeboy@comotivsystems.com>
> >Reply-To: "Log4J Users List" <log4j-user@logging.apache.org>
> >To: "Log4J Users List" <log4j-user@logging.apache.org>
> >Subject: RE: SMTPAppender only for ERROR and FATAL?
> >Date: Fri, 8 Oct 2004 12:48:31 -0700
> >
> >The fully qualfied class name of an evaluator that you provide.
> >
> >
> >-----Original Message-----
> >From:	None None [mailto:jappdev@hotmail.com]
> >Sent:	Fri 10/8/2004 12:43 PM
> >To:	log4j-user@logging.apache.org
> >Cc:
> >Subject:	RE: SMTPAppender only for ERROR and FATAL?
> >So according to that I have to....
> >
> ><appender name="email" class="org.apache.log4j.net.SMTPAppender">
> >	<param name="SMTPHost" value="SECORD"/>
> >	<param name="EvaluatorClass" value=""/>
> >	<param name="From" value="Application"/>
> >	<param name="To" value="dood@dood.com"/>
> >	<param name="Subject" value="Information"/>
> >	<layout class="org.apache.log4j.PatternLayout">
> >		<param name="ConversionPattern" value="%-4r %-5p [%t] %37c %3x - 
>%m%n"/>
> >	</layout>
> ></appender>
> >
> >What do I put for the value? Thanks
> > >From: "Scott Deboy" <sdeboy@comotivsystems.com>
> > >Reply-To: "Log4J Users List" <log4j-user@logging.apache.org>
> > >To: "Log4J Users List" <log4j-user@logging.apache.org>
> > >Subject: RE: SMTPAppender only for ERROR and FATAL?
> > >Date: Fri, 8 Oct 2004 12:27:01 -0700
> > >
> > >Javadoc here:
> > 
> >http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SMTPAppender.html
> > >
> > >If you are not providing an EvaluatorClass param you are using the
> >default
> > >evaluator.
> > >
> > >
> > >-----Original Message-----
> > >From:	None None [mailto:jappdev@hotmail.com]
> > >Sent:	Fri 10/8/2004 12:02 PM
> > >To:	log4j-user@logging.apache.org
> > >Cc:
> > >Subject:	SMTPAppender only for ERROR and FATAL?
> > >Am trying to set up a logger so I can send e-mails on speciffic events.
> > >Though it only seems an e-mail gets sent if the level is error, fatal 
>and
> > >above.
> > >
> > >So I get my logger.... and call myLogger.info("bla"); I get no 
>e-mail....
> > >So then I change it to myLogger.fatal("bla"); and and I get an e-mail!
> > >
> > >Below is my config file
> > >
> > ><?xml version="1.0" encoding="UTF-8" ?>
> > ><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> > >
> > ><log4j:configuration>
> > >	<appender name="console" class="org.apache.log4j.ConsoleAppender">
> > >		<layout class="org.apache.log4j.PatternLayout">
> > >			<param name="ConversionPattern" value="%-4r %-5p [%t] %37c %3x -
> >%m%n"/>
> > >		</layout>
> > >	</appender>
> > >	<appender name="file" class="org.apache.log4j.RollingFileAppender">
> > >		<param name="File" value="C:\\Programming\\logs.txt"/>
> > >		<param name="MaxFileSize" value="2KB"/>
> > >		<param name="MaxBackupIndex" value="5"/>
> > >		<layout class="org.apache.log4j.PatternLayout">
> > >			<param name="ConversionPattern" value="%-4r %-5p [%t] %37c %3x -
> >%m%n"/>
> > >		</layout>
> > >	</appender>
> > >	<appender name="email" class="org.apache.log4j.net.SMTPAppender">
> > >		<param name="SMTPHost" value="SECORD"/>
> > >		<param name="From" value="Application"/>
> > >		<param name="To" value="dood@dood.com"/>
> > >		<param name="Subject" value="Information"/>
> > >		<layout class="org.apache.log4j.PatternLayout">
> > >			<param name="ConversionPattern" value="%-4r %-5p [%t] %37c %3x -
> >%m%n"/>
> > >		</layout>
> > >	</appender>
> > >	<root>
> > >		<level value ="INFO"/>
> > >		<appender-ref ref="email"/>
> > >	</root>
> > >
> > ></log4j:configuration>
> > >
> > >_________________________________________________________________
> > >Take charge with a pop-up guard built on patented Microsoft® 
>SmartScreen
> > >Technology.
> > 
> >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
> > >   Start enjoying all the benefits of MSN® Premium right now and get 
>the
> > >first two months FREE*.
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > >For additional commands, e-mail: log4j-user-help@logging.apache.org
> > >
> > >
> > >
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > >For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >_________________________________________________________________
> >MSN® Calendar keeps you organized and takes the effort out of scheduling
> >get-togethers.
> >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
> >   Start enjoying all the benefits of MSN® Premium right now and get the
> >first two months FREE*.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>_________________________________________________________________
>MSN® Calendar keeps you organized and takes the effort out of scheduling
>get-togethers.
>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
>   Start enjoying all the benefits of MSN® Premium right now and get the
>first two months FREE*.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org

_________________________________________________________________
Don't just Search. Find! http://search.sympatico.msn.ca/default.aspx The new 
MSN Search! Check it out!


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