You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Henry Chou <na...@gmail.com> on 2009/05/28 19:49:34 UTC

Receiving LoggingEvent From SocketAppender (log4cxx 0.10.0)

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<http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/200805.mbox/%3C6df5775b0805200626h61d7f0b2ic1b9edc1a1e3a784@mail.gmail.com%3E>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.

Re: Receiving LoggingEvent From SocketAppender (log4cxx 0.10.0)

Posted by Curt Arnold <ca...@apache.org>.
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.



Receiving LoggingEvent From SocketAppender (log4cxx 0.10.0)

Posted by Henry Chou <na...@gmail.com>.
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<http://mail-archives.apache.org/mod_mbox/logging-log4cxx-user/200805.mbox/%3C6df5775b0805200626h61d7f0b2ic1b9edc1a1e3a784@mail.gmail.com%3E>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.