Hi Swarna,

Ah, fantastic. Swarna, I've been meaning to get to your mail (to me directly) for about a week now, but I wanted to "cc" my reply to the log4j list, since most of your questions are generic log4j questions, and not specific to the SNMPTrapAppender. (http://www.m2technologies.net/asp/snmpTrapAppender.asp)

1. Bender has already explained what you need to do in your Java code, to achieve what you want. But just to be sure it's clear, and using Bender's example further, here's what your code would then look like:

logger.warn("Logging a trap out to somewhere...") // this is *your* logger, the one you already had... mySnmpLogger.warn("This goes out to a trap") // this is the new, extra logger, that you use to send traps.

2. You don't install JoeSnmp, or Wengsoft, or Snmp4j, for that matter. You add the relevant Jar to your CLASSPATH, and that's it. Where that is/what that means is application specific, and you're going to have to tell us a whole lot more about your application, if you need us to help you with that.

3. The changes that you need to make in the log4j.xml file are rather extensively documented on my Web site, and in the Javadocs for the appender, which come with the download. See here -- http://www.m2technologies.net/html/doc/org/apache/log4j/ext/SNMPTrapAppender.html -- for example.

4. How can you test it? Now, that's a good question. There is no easy way to "catch" traps in a unit test, so it's difficult to do a pure unit test. If anybody has an idea on how to do this, I'd be all ears. In the meantime, if you've access to a Windows PC, I suggest Ncomtech's free Trap Receiver program (http://www.ncomtech.com/download.htm). Set it up to be the "listening end" (i.e. localhost and some free port in your log4j.xml, and set up the Trap Receiver to listen on this port), and you can use it to receive traps that you generate with your unit tests.

HTH.

Cheers,
Mark

Swarna Mani wrote:
My Name is Swarna. I am trying to implement generation of SNMP traps from Java
application using log4j. We already have log4j implemented for generating log
messages.

When I searched in the web, I came across posts in http://blog.gmane.org Wherein
it is explained that code like

logger.warn("Send a trap");
will generate a trap.

My question is we use similar one to generate logs, how can we distinguish
between entries for logs and entries for traps?

Also I find that it is mentioned that all we need to do is change the
configuration script. I am thinking of using JOESNMP.
Will it be possible for you to provide me the steps on

What needs to be coded in java application to differentiate logs and traps? Where do I install joesnmp? What changes I need to make to log4j.xml? How can I test the same?
Thanks in Advance,
Swarna




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to