Seine
May 26th, 2010, 06:55 AM
I've been trying to get syslogging to work from Java. The log4j syslogappender doesn't seem to work. I checked the implementation and it looked OK. So, I opened up RFC3164 (http://www.ietf.org/rfc/rfc3164.txt) and re-implemented it in Java. It still didn't work.
So then I tried to use /bin/nc and it still doesn't work. Perhaps I've misread the RFC. Here's what I'm trying.
/usr/bin/logger
# this works
logger -p user.info hello world
/bin/nc
# this doesn't work
echo "<14>May 26 15:23:83 Hello world" > nc -u localhost 514
JVM
// this doesn't work either
// (language is scala)
import java.net._
import java.io._
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
Can anyone see what I'm doing wrong?
So then I tried to use /bin/nc and it still doesn't work. Perhaps I've misread the RFC. Here's what I'm trying.
/usr/bin/logger
# this works
logger -p user.info hello world
/bin/nc
# this doesn't work
echo "<14>May 26 15:23:83 Hello world" > nc -u localhost 514
JVM
// this doesn't work either
// (language is scala)
import java.net._
import java.io._
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
Can anyone see what I'm doing wrong?