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 "Stefan.Borovac@t-online.de" <St...@t-online.de> on 2008/08/19 15:26:46 UTC
Socket and XMLSocketReceiver
Hi All,
I'am using log4cxx 0.10.0 and Chainsaw v2 as a server. On the Chainsaw
side I'am
using a SocketReceiver and a XMLSocketReceiver. Now I have three
beginner questions
concerning this setup.
1) The events logged by the XMLSocketReceiver are all written to the
"chainsaw-log" tab.
This is somehow ugly. Is it possible to set the "Application property"
such that the XML
messages are going to a different tab? I have found only vague
descriptions on setting
this property (even on the name of the key).
2) Question (1) is also a problem for the SocketReceiver, well different
tabs are open for
different remote hosts, but an application name is still missing.
3) While it was possible to send the "locationInfo" with the
XMLSocketAppender, the
same does not work on the SocketAppender/SocketReceiver pair, although
the C++ code
suggest that the location info is serialized. Any clou here?
Any help is welcome!
Cheers
Stefan
P.S.: Here is the Chainsaw config.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration >
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
<appender name="A2" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>
<plugin name="SocketReceiver"
class="org.apache.log4j.net.SocketReceiver" style="margin:0px;">
<param name="port" value="4560"/ style="margin:0px;">
<param name="name" value="mySocketReceiver"/ style="margin:0px;">
<param name="threshold" value="TRACE"/ style="margin:0px;">
</plugin>
<plugin name="XMLSocketReceiver"
class="org.apache.log4j.net.XMLSocketReceiver" style="margin:0px;">
<param name="decoder" value="org.apache.log4j.xml.XMLDecoder"/
style="margin:0px;">
<param name="port" value="4448"/ style="margin:0px;">
<param name="name" value="myXMLSocketReceiver"/
style="margin:0px;">
<param name="threshold" value="TRACE"/ style="margin:0px;">
</plugin>
<root>
<level value="debug"/>
</root>
</log4j:configuration>
And here the C++ config on the client side:
// XML socket stuff +++++++++++++++++++++++++++++++++++++++++++++++
XMLSocketAppenderPtr myXMLSocketAppender(
new XMLSocketAppender(
LOG4CXX_STR("XXX.XXX.XXX.XXX"),
4448
)
);
XMLLayoutPtr myXMLLayout( new XMLLayout() );
myXMLLayout->setLocationInfo(true);
myXMLSocketAppender->setLayout(myXMLLayout);
myXMLSocketAppender->activateOptions(pool);
// plain socket stuff +++++++++++++++++++++++++++++++++++++++++++++++
SocketAppenderPtr mySocketAppender(
new SocketAppender(
LOG4CXX_STR("XXX.XXX.XXX.XXX"),
4560
)
);
mySocketAppender->activateOptions(pool);
logger->addAppender(mySocketAppender);
logger->addAppender(myXMLSocketAppender);
logger->setLevel(log4cxx::Level::getDebug());
Re: Socket and XMLSocketReceiver
Posted by Stefan Borovac <St...@t-online.de>.
Hi Dale,
thanks for your answer and the usefull tips.
I have expected something like this but 2 1/2 years since
the last Chainsaw release is quite a bit too long.
We will see if we use Chainsaw at all.
Cheers
Stefan
Dale King wrote:
> On Tue, Aug 19, 2008 at 9:26 AM, Stefan.Borovac@t-online.de
> <ma...@t-online.de> <Stefan.Borovac@t-online.de
> <ma...@t-online.de>> wrote:
>
>
> Hi All,
>
> I'am using log4cxx 0.10.0 and Chainsaw v2 as a server. On the Chainsaw
> side I'am
> using a SocketReceiver and a XMLSocketReceiver. Now I have three
> beginner questions
> concerning this setup.
>
> 1) The events logged by the XMLSocketReceiver are all written to the
> "chainsaw-log" tab.
> This is somehow ugly. Is it possible to set the "Application property"
> such that the XML
> messages are going to a different tab? I have found only vague
> descriptions on setting
> this property (even on the name of the key).
>
>
> Yes the following will do it for the current thread. It is on a per
> thread basis so needs to be done per thread.
>
> log4cxx::MDC::put( "application", "my application name" );
>
>
>
> 3) While it was possible to send the "locationInfo" with the
> XMLSocketAppender, the
> same does not work on the SocketAppender/SocketReceiver pair, although
> the C++ code
> suggest that the location info is serialized. Any clou here?
>
>
> This is a known version compatibility issue with the released version of
> Chainsaw. The current version of Log4j is the 1.2.x branch which is what
> Log4Cxx is a port of. A long while back work was started on a new 1.3
> branch of Log4J. This branch was later abandoned and most of the
> features ported to the 1.2.x branch. There are differences between 1.2
> and 1.3 that mean that 1.2 serialized location info and MDC properties
> do not deserialize correctly in 1.3. The problem is that the currently
> released version of Chainsaw is built with the 1.3 branch of Log4J.
>
> For now stick to XMLSocketAppender. Feel free to complain loudly over on
> the Log4J forums about this. I find it unbelievable that there has been
> no new release of Chainsaw to fix this since the release of Chainsaw 2
> 1/2 years ago!
>
> You're welcome to try to build Chainsaw yourself against the 1.2 branch.
> Good luck, I've never been able to do it.
>
> Here is more info on this:
>
> http://markmail.org/message/ih7q5rgfckmlowaw#query:log4j%20chainsaw%20MDC+page:1+mid:ny52attu27fglhnl+state:results
>
> --
> Dale King
Re: Socket and XMLSocketReceiver
Posted by Dale King <da...@gmail.com>.
On Tue, Aug 19, 2008 at 9:26 AM, Stefan.Borovac@t-online.de <
Stefan.Borovac@t-online.de> wrote:
>
> Hi All,
>
> I'am using log4cxx 0.10.0 and Chainsaw v2 as a server. On the Chainsaw
> side I'am
> using a SocketReceiver and a XMLSocketReceiver. Now I have three
> beginner questions
> concerning this setup.
>
> 1) The events logged by the XMLSocketReceiver are all written to the
> "chainsaw-log" tab.
> This is somehow ugly. Is it possible to set the "Application property"
> such that the XML
> messages are going to a different tab? I have found only vague
> descriptions on setting
> this property (even on the name of the key).
>
Yes the following will do it for the current thread. It is on a per thread
basis so needs to be done per thread.
log4cxx::MDC::put( "application", "my application name" );
> 3) While it was possible to send the "locationInfo" with the
> XMLSocketAppender, the
> same does not work on the SocketAppender/SocketReceiver pair, although
> the C++ code
> suggest that the location info is serialized. Any clou here?
>
This is a known version compatibility issue with the released version of
Chainsaw. The current version of Log4j is the 1.2.x branch which is what
Log4Cxx is a port of. A long while back work was started on a new 1.3 branch
of Log4J. This branch was later abandoned and most of the features ported to
the 1.2.x branch. There are differences between 1.2 and 1.3 that mean that
1.2 serialized location info and MDC properties do not deserialize correctly
in 1.3. The problem is that the currently released version of Chainsaw is
built with the 1.3 branch of Log4J.
For now stick to XMLSocketAppender. Feel free to complain loudly over on the
Log4J forums about this. I find it unbelievable that there has been no new
release of Chainsaw to fix this since the release of Chainsaw 2 1/2 years
ago!
You're welcome to try to build Chainsaw yourself against the 1.2 branch.
Good luck, I've never been able to do it.
Here is more info on this:
http://markmail.org/message/ih7q5rgfckmlowaw#query:log4j%20chainsaw%20MDC+page:1+mid:ny52attu27fglhnl+state:results
--
Dale King