> I am looking to implement syslog server using Java (this syslog server
> captures all syslog messages whihc are coming on network, all machines
> on netwrok sends syslog messages),
> is there any API available to implement Syslog server using Java (to
> capture all syslog messages - UDP protocol, port 514)?. appreciated.
Is there any particular reason that you want to do this in Java? For a
large scale syslog server, you would be much better off using an
optimized language such as C.
And no, I'm not really on the bandwagon that C is faster than Java, but
for a specialised task such as this, where you have extreme volumes of
data, you probably DO want to do this in the fastest language available
to you.
For some more ideas on log analysis, take a look at loganalysis.org, and
also look for Marcus Ranum's discourse on log analysis on the
firewall-wizards list earlier this year.
Rogan
Chris Uppal - 20 Jun 2006 13:54 GMT
> And no, I'm not really on the bandwagon that C is faster than Java, but
> for a specialised task such as this, where you have extreme volumes of
> data, you probably DO want to do this in the fastest language available
> to you.
Here's a counter-view:
I'm not really on the bandwagon that java is better than C, but for a task such
as this, where you have uncontrolled, and potentially hostile, data sent to you
from anywhere on the network (or even the Net if your firewall's broken or
compromised), you probably don't want to use an unsafe language such as C.
;-)
In reality, of course, it mostly depends on what the OP wants to do, and what
constraints (performance and others) have to be satisfied.
But I know of no reason why a syslog listener couldn't be written in Java[*],
whether that is the optimal approach is another question.
-- chris
[*] A grossly over-simplified implementation:
import java.net.*;
import java.io.*;
public class Syslog
{
private static final int PORT = 514;
private static final int BUFFER_SIZE = 10000;
public static void
main(String[] args)
throws IOException
{
new Syslog().run();
}
private void
run()
throws IOException
{
DatagramSocket socket = new DatagramSocket(PORT);
DatagramPacket packet = new DatagramPacket(
new byte[BUFFER_SIZE],
BUFFER_SIZE);
for (;;)
{
packet.setLength(BUFFER_SIZE);
socket.receive(packet);
System.out.printf("Got %d bytes from %s%n",
packet.getLength(),
packet.getSocketAddress());
System.out.write(packet.getData());
System.out.println("==========");
}
}
}