Hi yourself!

>>Do you have any examples of using you classes?<<

First off, forgive me for copying my reply to the Log4J users list, but I get this 
question rather often, and I think it might help other folks to see the answer.

On to yor question -- you mean, Java code using Log4J where the SNMPTrapAppender is 
being used?  I'm not sure how this would be useful to you.  One of the key benefits of 
Log4J is the ability to use the logging functionality in application code without 
being concerned about how the actual logging itself is configured or implemented.  As 
far as the various appenders are concerned, the magic of Log4J is contained in the 
properties file.  This is what I mean on my Web site when I say that the only thing 
you need to do to use the appender is get it configured properly - this is true of any 
Log4J appender.

Actual code that *uses* Log4J is, in terms of information about the appenders being 
used, next to useless.  All you have is code like this:

Logger logger = Logger.getInstance(MyClass.class);

....


if (logger.debugIsEnabled) logger.debug("Log something!");

If you have an SNMPTrapAppender configured in your properties file, that line of code 
will cause an SNMP trap to be sent with the contents of the LoggingEvent as the text 
of the trap.  By the same token, if you've got a FileAppender configured for the same 
Logger (Category) in that properties file, the same statement in code will also write 
a line out to a file.  The point is, none of this is apparent from, or has an effect 
on, the code you write in your application.  And that's a good thing!  :-)

On the download page for the SNMPTrapAppender, I have examples of using both "normal" 
and XML based properties files with the SNMPTrapAppender.  They should be enough to 
get you started.  If you have more questions, then don't hesitate to ask!

Cheers,
Mark


Reply via email to