20

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.

Community
  • 1
  • 1
  • 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. – Adam Batkin Jun 01 '11 at 20:02
  • I know you're not looking for SLF4J, but I still heartily recommend it even if you'll be using util-logging underneath. – Darien Jun 01 '11 at 22:51
  • 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. – bestsss Jun 01 '11 at 23:59
  • Eventually, there will be a syslog writer for Tinylog: https://github.com/tinylog-org/tinylog/issues/156 – koppor Mar 27 '23 at 12:34

3 Answers3

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.

Nulldevice
  • 3,926
  • 3
  • 31
  • 37
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.

Darien
  • 3,482
  • 19
  • 35
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.

simon.watts
  • 976
  • 10
  • 14