logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moley Harey <moleyha...@gmail.com>
Subject Re: Problems with log4j SimpleSocketServer connection
Date Thu, 26 Mar 2009 17:51:00 GMT
Hi againScott, sorry to disturb you with this...

I have added the appender in my Log4j config file and now it looks like:

<?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="NRTPXmlSocketReceiver" />
     <param name="port" value="4445" />
   </plugin>

   <appender name="RollingAppender"
class="org.apache.log4j.RollingFileAppender">
     <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
     <param name="File" value="/data/logs/chainsaw.log"/>
     <param name="Append" value="false"/>
     <param name="MaxFileSize" value="20000KB"/>
     <param name="MaxBackupIndex" value="400"/>
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d | %-5r | %-5p | %c | %t:%x
| %m%n"/>
     </layout>
   </appender>

   <root>
      <level value="debug"/>
   </root>
</log4j:configuration>

When I start Chainsaw, the log file chainsaw.log file is created but once my
application is sending messages and they get displayed in the log file
nothing is saved :S

Do I have to add anything else? The syntax is correct for the appender? I
have followed Log4j conventions...

2009/3/26 Scott Deboy <scott.deboy@gmail.com>

> Correct - you can add appender definitions to the same Chainsaw
> configuration file that contains the receiver definition, and the appenders
> will process the events received by Chainsaw.
>
> Scott
>
> On Thu, Mar 26, 2009 at 10:18 AM, Moley Harey <moleyharey@gmail.com>
> wrote:
>
> > Hi Scott,
> >
> > 2009/3/26 Scott Deboy <scott.deboy@gmail.com>
> >
> > > You can include in Chainsaw's configuration any appenders you'd like,
> > which
> > > will cause any events received by the receivers to be propagated to the
> > > appenders automatically.
> >
> >
> > How can I do that?
> > What I am doing now is to launch Chainsaw and when I am prompted at the
> > beginning that no receivers have been defined I select the option "Let me
> > search for a configuration file" and then load my config file that
> contains
> > the following code to define my own XmlSocketReceiver:
> >
> > <?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="NRTPXmlSocketReceiver" />
> >     <param name="port" value="4445" />
> >    </plugin>
> >
> >   <root>
> >      <level value="debug"/>
> >   </root>
> > </log4j:configuration>
> >
> > What you say is that is possible to define in that configuration file too
> > one appender that redirects all messages that the XmlSocketReceiver is
> > reading and the display is showing to a text log file in the same way is
> > done usually in a log4j properties file with a RollingFileAppender for
> > example?
> >
> > Or do I have to define this appender in a separate file and load it too
> in
> > Chainsaw?
> >
> > >
> > >
> > > You can also save logging events as XML in Chainsaw via the file menu
> > > (note,
> > > whatever events are displayed are saved, so you can apply filters if
> > you'd
> > > like to only save relevant messages).
> > >
> > > Scott
> > >
> > > On Thu, Mar 26, 2009 at 9:31 AM, Moley Harey <moleyharey@gmail.com>
> > wrote:
> > >
> > > > 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 <moleyharey@gmail.com>
> > > >
> > > > > 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 <dmiperl@gmail.com>
> > > > >
> > > > > 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 <dmiperl@gmail.com>
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>>> 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:
> log4j-user-unsubscribe@logging.apache.org
> > > > >>>> For additional commands, e-mail:
> > log4j-user-help@logging.apache.org
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > ---------------------------------------------------------------------
> > > > >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > > > >> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > — 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/
> > > >
> > >
> >
> >
> >
> > --
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > — 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/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message