logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Deboy" <sde...@comotivsystems.com>
Subject RE: Anyone using SNMPTrapAppender?
Date Sun, 18 Jul 2004 17:06:39 GMT
Wouldn setting the host name as an mdc entry and then using the mdc conversion pattern mechanism

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.

-----Original Message-----
From:	Schuhmacher, Bret [mailto:Bret.Schuhmacher@Aspect.com]
Sent:	Fri 7/16/2004 8:51 AM
To:	Log4J Users List
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!!

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message