You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Robert Kausch <rk...@gmail.com> on 2005/11/10 00:44:10 UTC

Help using a SocketAppender and getting hostname / IP information

I have a question regarding using the SocketAppender and a socket server (be
it SimpleSocketServer, or some other implementation). In my environment, I
have many different (smallish) Java applications, on separate machines, that
all use Log4J, and I reconfigured them all to use a SocketAppender. That
part's actually pretty easy. The difficult part that I'm running into is
that when I'm processing the incoming log event object, I would like to add
information about the system from which the log message was generated (such
as the hostname, IP address, etc). Ideally, I'd like to extend the
PatternFormat class to allow the formatting of these additional fields
(instead of simply adding the hostname and IP when the message is received).
I've messed around with extending the Logger class, the LoggingEvent class,
and several others. My current (and highly undesirable) solution is to
actually modify the log4j source so that when a Logger is retrieved, using
the built-in java.net <http://java.net> classes, I can automatically grab
the information from the host on which the message is being generated, and
populate it into a LoggingEvent.

Am I completely missing a standardized way of doing this? Any help is
greatly appreciated!

Thanks!
Robert