logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Receiving LoggingEvent From SocketAppender (log4cxx 0.10.0)
Date Fri, 29 May 2009 04:16:05 GMT

On May 28, 2009, at 12:57 PM, Henry Chou wrote:

> Hello,
>
> I have scoured through the mailing list archive and found nothing  
> that suits my desired outcome. I want to be receiving a LoggingEvent  
> from a server, then parsing the event (ie: reconstructing a pattern  
> by calling the getTimeStamp(), getLevel(), and getMessage()  
> functions (iee: "%d [%p] - %m%n"), or the \pattern\
> LoggingEventPatternConverter.cpp). Can anyone provide some example  
> code for this to happen?
>
> I realize that I can use XMLSocketAppender, coupled with an  
> PatternLayout to send a simple text string through TCP to the  
> server. However, I need to be parsing these LoggingEvents in such a  
> way that different tasks are to be done; this would mean that I  
> would then have to parse a string which would not be ideal. With a  
> LoggingEvent received from the server, I would be able to  
> reconstruct, or even send the LoggingEvent to another server if for  
> different log levels when using \spi\TriggeringEventEvaluator.cpp.
>
> Ruud Bos has had a problem similar to my own, but was solved by  
> switching versions to log4cxx 0.9.7. I do not want addition packages  
> such as Chainsaw, or log4j.
>
> Once again, the question is simple: is there example code around for  
> a server to receive LoggingEvents generated by SocketAppender? Just  
> for clarification, is SocketAppender sending a LoggingEvent at all  
> or some other type of structure? If so, how would the server handle  
> that?
>
> Thanks ahead of time,
>
> -hc.


SocketAppender is sending a serialized form of LoggingEvent that is  
designed to be compatible with code that receives LoggingEvents from  
log4j 1.2 (such as Chainsaw).  log4cxx 0.9.7 used a serialized form  
that varied depending on character type, endianness and, I think, the  
size of pointers and ints.

While it would be difficult to write in C++ a receiver that could  
handle messages from log4j since events could include any arbitrary  
Java class as message parameters, it would not be particularly  
difficult to handle messages if they were known to only come from  
log4cxx since that format is very deterministic.

I would suggest too get started receiving events from  
XMLSocketAppender and see whether the XML parsing overhead is really  
significant for your application.  If you find that it is, then you  
could modify the code to receive the serialized form output by  
SocketAppender.



Mime
View raw message