Hi again, I have done the following test and is working fine:
1. Update my log4cxx.properties file to send all messages through a XmlSocketAppender like this: log4j.appender.A1=org.apache.log4j.net.XmlSocketAppender log4j.appender.A1.Port=4560 log4j.appender.A1.RemoteHost=127.0.0.1 2. Launch Chainsaw with teh following configuration file that specifies it should be using an XmlSocketReceived like this: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <plugin name="XmlSocketReceiver" class="org.apache.log4j.net.XMLSocketReceiver"> <param name="active" value="false"/> <param name="decoder" value="org.apache.log4j.xml.XMLDecoder"/> <param name="name" value="MyXmlSocketReceiver" /> <param name="port" value="4560" /> </plugin> <root> <level value="debug"/> </root> </log4j:configuration> This is working OK, Chainsaw registers without problem the new receiver "MyXmlSocketReceiver" and log messages sent by my C++ application are correctly displayed, so clearly the problem was in the SimpleSocketServer that I used. One question, what I initially wanted was to write in a single log file all those messages, but now that Chainsaw allows me to display and include the SocketServer that understands "XmlSocket" formatted messages I was thinking adding to Chain saw code the feature to write in a single log file and I would have all I need plus a nice display... Do you think this is feasible? Does Chainsaw bring the feature not only to display messages but to save them into a log file? Thanks in advance, Mh 2009/3/26 Moley Harey <[email protected]> > Hi Dmitry and old, > > Do you know if the available SimpleSocketServer already include the > possibility of using it with a XMLSocketReceiver? > Or does log4j provide something similar to the code used in Chainsaw? > > Thanks in advance, > > Mh > > 2009/3/26 Dmitry <[email protected]> > > On the server side you must use XML based receiver as well. >> Non java applications (c,c++,.net,etc..) must send logging events in XML >> serialized form and get reconstructed on the server into Java objects from >> this XML. >> >> -- >> Kind regards, >> Dmitry >> >> www.moonlit-software.com >> >> Moley Harey wrote: >> >>> Hi, thanks for your answers... >>> >>> I changed the appender in my log4cxx properties file to be a >>> XMLSocketAppender and now I get the following exception when trying to >>> connect to my SocketServer: >>> >>> 2009-03-26 09:35:08,528 INFO NRTSocketServer - NRTSocketServer :: >>> Connected >>> to client at /127.0.0.1 >>> 2009-03-26 09:35:08,528 INFO NRTSocketServer - NRTSocketServer :: >>> Starting >>> new socket node. >>> 2009-03-26 09:35:08,534 ERROR org.apache.log4j.net.SocketNode - Could not >>> open ObjectInputStream to Socket[addr=/127.0.0.1 >>> ,port=37049,localport=4445] >>> java.io.StreamCorruptedException: invalid stream header >>> at >>> java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:764) >>> at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277) >>> at org.apache.log4j.net.SocketNode.<init>(SocketNode.java:55) >>> at NRTSocketServer.main(NRTSocketServer.java:46) >>> >>> My SocketServer is based on the log4j Java class SimpleSocketServer, is >>> this >>> class able to receive XML messages sent by log4cxx using >>> XMLSocketAppender? >>> Or do I have to implement a different Java SocketServer that understand >>> these messages? >>> >>> 2009/3/25 Dmitry <[email protected]> >>> >>> >>> >>>> You must use XMLSocketAppender to send log from any non-Java client to >>>> Java >>>> server. >>>> Put something like this into your C++ properties file : >>>> log4j.appender.A1=org.apache.log4j.net.XMLSocketAppender >>>> log4j.appender.A1.RemoteHost=localhost >>>> log4j.appender.A1.Port=12345 >>>> It should work.. >>>> >>>> Kind regards, >>>> Dmitry >>>> http://www.moonlit-software.com >>>> >>>> >>>> Moley Harey wrote: >>>> >>>> >>>> >>>>> Hi folks, >>>>> >>>>> I have implemented a Java SimpleSocketServer application that is >>>>> running >>>>> with log4j version 1.2, I have done a test Java class that initialize >>>>> the >>>>> logging and sends a couple of messages to the SimpleSocketServer and >>>>> works >>>>> fine, all messages sent by the test class are succesfully written in >>>>> the >>>>> same log file. >>>>> >>>>> Then I have done the same with a C++ log4cxx application, updating the >>>>> log4cxx.properties file to be like this: >>>>> >>>>> log4j.rootCategory=DEBUG,stdout,A1 >>>>> >>>>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender >>>>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout >>>>> >>>>> log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n >>>>> >>>>> # A1 is set to be a SocketAppender sending its output to the server >>>>> running >>>>> on the remote host, port 4445 >>>>> log4j.appender.A1=org.apache.log4j.net.SocketAppender >>>>> log4j.appender.A1.Port=4445 >>>>> log4j.appender.A1.RemoteHost=127.0.0.1 >>>>> >>>>> I have run my C++ application and what I get in my log file are just >>>>> the >>>>> following messages: >>>>> >>>>> 2009-03-25 17:14:33,914 INFO NRTSocketServer - NRTSocketServer :: >>>>> Connected >>>>> to client at /127.0.0.1 >>>>> 2009-03-25 17:14:33,969 INFO NRTSocketServer - NRTSocketServer :: >>>>> Starting >>>>> new socket node. >>>>> >>>>> And after this no debug or info message is logged, just when my C++ >>>>> application has finished I get the following message: >>>>> >>>>> 2009-03-25 17:16:25,290 ERROR org.apache.log4j.net.SocketNode - Could >>>>> not >>>>> open ObjectInputStream to Socket[addr=/127.0.0.1 >>>>> ,port=36965,localport=4445] >>>>> java.io.EOFException >>>>> at >>>>> >>>>> >>>>> java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2228) >>>>> at >>>>> >>>>> >>>>> java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2694) >>>>> at >>>>> java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:761) >>>>> at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277) >>>>> at org.apache.log4j.net.SocketNode.<init>(SocketNode.java:55) >>>>> at NRTSocketServer.main(NRTSocketServer.java:46) >>>>> >>>>> So from logging messages from Java application using log4j to Java >>>>> ServerSocket works fine, but from C++ application using log4cxx 0.10 >>>>> does >>>>> not work... >>>>> >>>>> Could be the problem the type of Appender I am using? Maybe I should >>>>> use >>>>> something like XMLSocketAppender or so? >>>>> >>>>> Thanks in advance, >>>>> >>>>> Mh >>>>> >>>>> >>>>> >>>>> >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>>> >>>> >>> >>> >>> >>> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > — Las cosas que vemos —dijo Pistorius con voz apagada— son las mismas cosas > que llevamos en nosotros. > No hay más realidad que la que tenemos dentro. (Herman Hesse) > > http://moleyharey.blogspot.com/ > -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ — Las cosas que vemos —dijo Pistorius con voz apagada— son las mismas cosas que llevamos en nosotros. No hay más realidad que la que tenemos dentro. (Herman Hesse) http://moleyharey.blogspot.com/
