user177800
user177800

Reputation:

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

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.

Upvotes: 21

Views: 20642

Answers (3)

simon.watts
simon.watts

Reputation: 1095

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.

Upvotes: 1

Nulldevice
Nulldevice

Reputation: 4006

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.

Upvotes: 12

Darien
Darien

Reputation: 3592

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.

Upvotes: 2

Related Questions