Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 94334 invoked from network); 13 Feb 2006 19:51:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Feb 2006 19:51:48 -0000 Received: (qmail 54125 invoked by uid 500); 13 Feb 2006 19:51:44 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 54094 invoked by uid 500); 13 Feb 2006 19:51:44 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 54083 invoked by uid 99); 13 Feb 2006 19:51:44 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2006 11:51:44 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [194.25.134.19] (HELO mailout06.sul.t-online.com) (194.25.134.19) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2006 11:51:43 -0800 Received: from fwd27.aul.t-online.de by mailout06.sul.t-online.com with smtp id 1F8jjE-0002DC-05; Mon, 13 Feb 2006 20:51:20 +0100 Received: from Balder.local (bKTVocZCoeJ1AqnRZ2uQRaFWwtSC+kp3GJ2InQp+0IqVqOWonE86Ew@[84.169.211.34]) by fwd27.sul.t-online.de with esmtp id 1F8jj5-1UNsjw0; Mon, 13 Feb 2006 20:51:11 +0100 Received: from [127.0.0.1] by Balder.local (PGP Universal service); Mon, 13 Feb 2006 20:51:14 +0100 X-PGP-Universal: processed; by Balder.local on Mon, 13 Feb 2006 20:51:14 +0100 Message-ID: <43F0E32F.8070607@compuserve.com> Date: Mon, 13 Feb 2006 20:51:11 +0100 From: Mark Masterson Reply-To: m.masterson@computer.org User-Agent: Thunderbird 1.5 (Macintosh/20051201) MIME-Version: 1.0 To: Log4J Users List Subject: Re: Generating SNMP traps from Java Application References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ID: bKTVocZCoeJ1AqnRZ2uQRaFWwtSC+kp3GJ2InQp+0IqVqOWonE86Ew@t-dialin.net X-TOI-MSGID: 69751f3c-6468-456e-bf40-2048711e5994 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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: 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