How can I get Syslogging to work on the JVM?
Posted
by Synesso
on Stack Overflow
See other posts from Stack Overflow
or by Synesso
Published on 2010-05-26T06:12:31Z
Indexed on
2010/05/26
6:21 UTC
Read the original article
Hit count: 237
I want to do syslogging from Java. There is a log4j appender, but it doesn't seem to work (for me anyway ... though Google results show many others with this issue still unresolved).
I'm trying to debug the appender, so I've written the following script based upon RFC3164
It runs, but no logging appears in the syslog.
// scala
import java.io._
import java.net._
val ds = new DatagramSocket()
val fullMsg = "<11>May 26 14:47:22 Hello World"
val packet = new DatagramPacket(fullMsg.getBytes("UTF-8"), fullMsg.length,
InetAddress.getLocalHost, 514)
ds send packet
ds.close
I also tried using /bin/nc, but it doesn't work either.
echo "<14>May 26 15:23:83 Hello world" > nc -u localhost 514
The Ubuntu command /usr/bin/logger does work, however.
logger -p user.info hello world
# logs: May 26 15:25:10 dsupport2 jem: hello world
What could I be doing wrong?
© Stack Overflow or respective owner