On May 15, 2008, at 9:45 AM, Ruud Bos wrote:

Hello,

I'm new to the list, so I have no idea if this question has been asked many times before. I hope someone can put me in the right direction.

I'd like to use log4cxx for two applications. One acts as a client that needs to send it's logging to a server application using socket communication. Both programs are written in C++.

From the few things I could find on the internet about the use of the ServerSocket class, I was not able to create something that works. Most of these only talk about the client side and use the java substitute log4j for the server side.

If someone could point me to some example code, that would be extremely helpful.

Thanks in advance,
Ruud



log4cxx 0.9.7 came with an implementation of both the client and server side for SocketAppender, but used its own format that was not platform independent. So if the sender and receiver differed in endianness, character type, int length or the like, bad things would happen.

log4cxx 0.10.0 replaced that with an implementation that produced a stream format compatible with log4j's format (the Java serialization of its LoggingEvent class). This allows interoperability with Chainsaw and eliminated the platform variation of the format.

There is a huge degree of variability allowed with Java serialization so it is much easier to write a logging event that can be read by Java serialization than reliably read a logging event written by Java serialization. You could write code that read log4cxx's specific take on it, but that would be unlikely to reliably read events from log4j.

If you were going to receive events from log4cxx, I would suggest using the XMLSocketAppender as the format would require less custom code to parse the stream format. I'm sorry, but I'm not aware of any sample code for it.


Reply via email to