logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schuhmacher, Bret" <Bret.Schuhmac...@Aspect.com>
Subject RE: Anyone using SNMPTrapAppender?
Date Sun, 18 Jul 2004 19:02:40 GMT
Thanks for the idea, Scott.  I don't know anything about MDC (yet), but
I'll look into it! :-)  Ideally what I'd like is something of a cross
between a printf and an ODBC parameter binding.  Each specified variable
piece of text would get it's own varbind, based on the delimited
conversion pattern.  For example, if I write this:
myLog.debug("Host: <" + strHostXYZ + "> port: <" + intPortXYZ + ">
reported error: <" + strErrorXYZ + ">");

The conversion pattern would strip out the stuff in the brackets and put
each in its own SNMP varbind.  That's what I thought the
DelimitedConversionPattern class would do for me.  But, hey, I've got
the source, right? ;-)



> -----Original Message-----
> From: Scott Deboy [mailto:sdeboy@comotivsystems.com] 
> Sent: Sunday, July 18, 2004 1:07 PM
> To: Log4J Users List
> Subject: RE: Anyone using SNMPTrapAppender?
> Wouldn setting the host name as an mdc entry and then using 
> the mdc conversion pattern mechanism work?
> The thread that generates the events which require the 
> hostname param should set the hostname MDC entry prior to 
> generating events:
> MDC.put("hostname", "myhost");
> Any log entry generated on the thread after the MDC entry is 
> set will automatically have the hostname entry.  No need to 
> specify it in the message text.  Instead, you log your message:
> myLog.debug("my debug message");
> In the next version of log4j, a number of the network-based 
> appenders support hostName and application params specified 
> in the config file since they are so commonly needed.
> If set, these properties are provided with every event (no 
> need to call mdc.put on each thread).  Maybe smtpTrapAppender 
> could be enhanced to provide this functionality as well. 
> Arbitrary name/value pairs would still need set via MDC.
> Scott
> -----Original Message-----
> From:	Schuhmacher, Bret [mailto:Bret.Schuhmacher@Aspect.com]
> Sent:	Fri 7/16/2004 8:51 AM
> To:	Log4J Users List
> Cc:	
> Subject:	Anyone using SNMPTrapAppender?
> I need a little push in the right direction, please...
> I have a question about using the DelimitedConversionPattern 
> from inside my program that's doing the logging.  Right now I 
> have something like this:
> myLog.debug("my debug message from host " + strHostName);
> This writes a single string to the SNMP Trap appender like this:
> my deug message from host xyzhost
> Now I need to do variable bindings and I'm not sure how the 
> actual log statement in the java source must change to 
> accommodate the delimited conversion pattern.  Should I 
> delimit the log setting like this?
> myLog.debug("my debug message from host ;" + strHostName);
> this line puts a ";" in the log string so that, hopefully, 
> the delimited conversion pattern will extract that as two 
> strings - one containing "my debug message from host" and 
> another with "xyzhost".  Is this correct?
> If someone can merely supply me a line of working log code 
> that uses the SNMPDelimitedConversionPattern and possibly the 
> actual pattern from their rc or xml file I'd be really grateful!
> Thanks in advance!!
> Rgds,
> Bret
> ---------------------------------------------------------------------
> 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

View raw message