You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by lo...@spamgourmet.com on 2006/02/28 05:46:12 UTC

[log4j] SocketAppender with Chainsaw?

Hello folks,

I am trying to connect a C++ application using log4cxx to a Chainsaw client 
(on the same machine for now)

Following the advice of Scott Deboy, I used XMLSocketAppender in the app's 
log4j config file and XMLSocketReceiver (port 4560) in chainsaw. The app's 
log4j config file is:

------
# Forces log4j to display messages while parsing this config file
log4j.debug=true

# Set root logger level to ALL, appender CONS
log4j.rootLogger=ALL, SOCK, CONS

# Define appender CONS
log4j.appender.CONS=org.apache.log4j.ConsoleAppender
log4j.appender.CONS.layout=org.apache.log4j.SimpleLayout

# Define appender SOCK
log4j.appender.SOCK=org.apache.log4j.net.XMLSocketAppender
log4j.appender.SOCK.RemoteHost=localhost
log4j.appender.SOCK.Port=4560
log4j.appender.SOCK.LocationInfo=false
------

Unfortunately, when I run the application generating the log events, I see  
messages only on the console. Chainsaw  never shows these logs events and 
only displays an error. It sees the socket connection from the app but 
immediately closes the socket, with a message "no bytes read from stream - 
closing connection". The XML dump of the relevant Chainsaw messages is listed 
below.

So my question is: what am I doing wrong? What is the correct 
appender/receiver combo for sockets?

Chainsaw error messages (content of chainsaw-log tab)

<log4j:event logger="org.apache.log4j.net.XMLSocketReceiver" 
timestamp="1141089218920" sequenceNumber="187" level="DEBUG" 
thread="Chainsaw-WorkerThread">
<log4j:message><![CDATA[accepted socket]]></log4j:message>
<log4j:properties>
    <log4j:data name="application" value="log"/>
    <log4j:data name="hostname" value="chainsaw"/>
    <log4j:data name="log4jid" value="1"/>
</log4j:properties>
</log4j:event>

<log4j:event logger="org.apache.log4j.net.XMLSocketReceiver" 
timestamp="1141089218920" sequenceNumber="188" level="DEBUG" 
thread="Chainsaw-WorkerThread">
<log4j:message><![CDATA[socket not null - creating and starting 
socketnode]]></log4j:message>
<log4j:properties>
    <log4j:data name="application" value="log"/>
    <log4j:data name="hostname" value="chainsaw"/>
    <log4j:data name="log4jid" value="2"/>
</log4j:properties>
</log4j:event>

<log4j:event logger="org.apache.log4j.net.XMLSocketReceiver" 
timestamp="1141089218925" sequenceNumber="189" level="DEBUG" 
thread="Chainsaw-WorkerThread">
<log4j:message><![CDATA[waiting to accept socket]]></log4j:message>
<log4j:properties>
    <log4j:data name="application" value="log"/>
    <log4j:data name="hostname" value="chainsaw"/>
    <log4j:data name="log4jid" value="3"/>
</log4j:properties>
</log4j:event>

<log4j:event logger="org.apache.log4j.net.XMLSocketNode" 
timestamp="1141089218926" sequenceNumber="190" level="INFO" 
thread="Chainsaw-WorkerThread">
<log4j:message><![CDATA[no bytes read from stream - closing 
connection.]]></log4j:message>
<log4j:properties>
    <log4j:data name="application" value="log"/>
    <log4j:data name="hostname" value="chainsaw"/>
    <log4j:data name="log4jid" value="4"/>
</log4j:properties>
</log4j:event>



    / Fred Mora - Advanced Platform Services
   / IBM Research - Hawthorne (USA)


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org