Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30023
| From | Kevin McMurtrie <mcmurtrie@pixelmemory.us> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: log4j socket appender |
| References | <64807899-4e1f-4a12-853b-ad521a27ec48@googlegroups.com> <lvjiei$djk$1@gwaiyur.mb-net.net> |
| Date | 2014-09-20 10:17 -0700 |
| Message-ID | <mcmurtrie-4CD242.10172620092014@news.sonic.net> (permalink) |
| Organization | Sonic.Net |
In article <lvjiei$djk$1@gwaiyur.mb-net.net>,
Marcel Mueller <news.5.maazl@spamgourmet.org> wrote:
> On 19.09.14 22.34, doug.farrell@gmail.com wrote:
> > and has a log4j.xml configuration file that looks like this:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <Configuration status="WARN">
> > <Appenders>
> > <Console name="STDOUT" target="SYSTEM_OUT">
> > <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
> > %msg%n"/>
> > </Console>
> > <Socket name="SOCKET" host="localhost" port="9023" protocol="UDP">
> > <SerializedLayout />
> ^
> This is probably not what you want ...
>
> > However, I can't figure out what the format of the data received by the
> > Python logging server is? This is the data I get back in my handler:
> >
> > '\xac\xed\x00\x05sr\x00>org.apache.logging.log4j.core.impl.Log4jLogEvent$Log
> > EventProxy...
>
> ... because of this.
>
> If you are unhappy with log4j SocketAppender and you cannot depend on
> log4j 2, simply write your own appender. This is quite simple. You
> basically need to derive from AppenderSkeleton and implement the method
> append (who'd a thunk). There you can do whatever you like with the
> LogEvent passed as an argument.
> Alternatively you might extend WriterAppender and pass an
> UDPOutputStream (Apache license as log4j is) to the constructor.
>
> This also works if you do not own the logging application as long as you
> can add your class to the JVM classpath. BTDT.
>
>
> Marcel
I'm not a fan of Log4J. I haven't seen it perform well and configuring
it to work as you wish becomes complicated. Formatting log entries with
hostile content (control characters, toString() throws, etc.) is
definitely a weak spot. I need a custom formatter that won't trash the
logs if somebody injects binary data into a text workflow.
I've been using the Java logging framework. It's trivial to implement
and it lets you take advantage of high performance/high concurrency
libraries that you may already be using. Since handlers are easy to
configure runtime, you can do neat stuff like temporarily change log
levels and replicate a log path to a WebSocket.
Sun's auto configuration system is a poorly documented wreck but it's
easy enough to read in a list of Handlers and log paths from a config
file yourself.
--
I will not see posts from astraweb, theremailer, dizum, or google
because they host Usenet flooders.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
log4j socket appender doug.farrell@gmail.com - 2014-09-19 13:34 -0700
Re: log4j socket appender Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-09-19 16:48 -0400
Re: log4j socket appender markspace <markspace@nospam.nospam> - 2014-09-19 17:17 -0700
Re: log4j socket appender doug.farrell@gmail.com - 2014-09-22 08:29 -0700
Re: log4j socket appender Nigel Wade <nmw@ion.le.ac.uk> - 2014-09-23 12:35 +0100
Re: log4j socket appender doug.farrell@gmail.com - 2014-10-02 06:23 -0700
Re: log4j socket appender Marcel Mueller <news.5.maazl@spamgourmet.org> - 2014-09-20 11:46 +0200
Re: log4j socket appender Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2014-09-20 10:17 -0700
Re: log4j socket appender markspace <markspace@nospam.nospam> - 2014-09-20 13:29 -0700
Re: log4j socket appender Jeff Higgins <jeff@invalid.invalid> - 2014-09-20 23:05 -0400
csiph-web