What is the most modern way to log to syslog using a java.util.logging handler?
Asked Answered
S

3

21

I am specifically looking for the most up to date, modern SysLogHandler for java.util.logging.

I have found a few that date back to 2001 - 2003, mostly un-supported now.

I know that syslog is a pretty static service, I am wondering before I write something myself, if there are any newer handler implementations that support the Java 1.5 and newer features.

I am not interested in any of the other logging frameworks or wrapper / proxy libraries.

I am not looking for SLF4J or any other alternative logging frameworks, as suggested in this question.

Should answered 1/6, 2011 at 20:0 Comment(4)
You could write some code to do it. Or use a library that can already do it. Since Java can't do it out of the box.Goodlooking
I know you're not looking for SLF4J, but I still heartily recommend it even if you'll be using util-logging underneath.Wallpaper
write it yourself, probably it'd have less time than the discussion here. I know, if I need a handler I just write it myself. java.util.logging was practically unchanged in java5, in 6_18 they made some weak reference to the loggers.Peyote
Eventually, there will be a syslog writer for Tinylog: github.com/tinylog-org/tinylog/issues/156Ovoviviparous
M
12

I met same problem - I was need a Syslog extension class for java.util.logging.Handler

After searching in Internet without any success, I ended up creating my own implementation - http://code.google.com/p/agafua-syslog/ with support of UDP and TCP protocols. I use it in production project.

Marengo answered 24/9, 2012 at 19:53 Comment(2)
For use with tomcat it should be installed to $CATALINA_HOME/endorsed.Cipher
Due to a deprecation of Google Code project migrated to rusv.github.io/agafua-syslogInterval
W
2

In an old job, I used the Syslog4j library and wired up a custom Log4j-appender for it, so you can probably do something similar by implementing a custom java.util.logging.Handler that passes messages along.

Wallpaper answered 1/6, 2011 at 22:52 Comment(1)
syslog4j link seems to be broken :-(Supercharger
M
1

Syslog (at least on Linux) listens on a UDP port for input (514/udp by default).

So implement a Handler which sends the formatted messages to this port. I used the existing SocketHandler for reference, and implemented an alterative around a DatagramSocket. Mine came to about 200 lines all-in.

Melancholic answered 18/9, 2014 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.