Hi, Mark:

In LoggingEvent of chainsaw, it has the following code snippet:

===============================================
 /** socket connection to read events from **/
        private final Socket mClient;
......

final ObjectInputStream ois = new
ObjectInputStream(mClient.getInputStream());
                while (true) {
                    final LoggingEvent event = (LoggingEvent)
ois.readObject();
                    mModel.addEvent(new EventDetails(event));
                }
=================================================================

As the code showed above, it uses readObject of ObjectInputStream to get the
LoggingEvent. I am a little confused here: the SocketHubAppender defines the
destination of the LoggingEvent(in my case, the swing application is the
destination of the LoggingEvent). From my understanding, when the log is
requested from the web application, the LoggingEvent is automatically passed
to destination(in my case, the swing application). Why we need to write code
to get the LoggingEvent from the web application(as the code showed above)?



============================================================================
======================
I tried to use the same approach as the way of chainsaw. The following is my
code snippet:

  final ObjectInputStream ois = new ObjectInputStream(
socket.getInputStream() );   //LINE1
      while ( true ){
                     //LoggingEventHolder is a regular class to hold the
LoggingEvent
                     LoggingEventHolder aHolder = new LoggingEventHolder();
                     Holder.addEvent((LoggingEvent)ois.readObject());
                }

After it excutes LINE1,which is "final ObjectInputStream ois = new
ObjectInputStream( socket.getInputStream() );", it shows "EOF exception".
For debug purpose, I printed out the socket. The socket printed on the
console is: Socket[addr=localhost/127.0.0.1,port=7001,localport=4423](The
addr and port is the addr and port of the web application).

I am not sure what's wrong with the above code. I would appreciate your
suggestions and idea.
Sorry to bother you. Thank you very much for your time and help.



Best regards,
Nancy




----- Original Message -----
From: "Mark Womack" <[EMAIL PROTECTED]>
To: "'Log4J Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, February 11, 2003 12:15 AM
Subject: RE: Urgent---Help please


> Some examples of how to receive LoggingEvents in the log4j source:
>
> org.apache.log4j.chainsaw.LoggingReceiver - Since Chainsaw is a swing gui
> viewer, it should serve as the best example for your needs, I would think.
> The LF5 package may have some useful code as well.
> org.apache.log4j.net.SimpleSocketServer;
> org.apache.log4j.net.SocketNode - These work together to recieve
> LoggingEvents and post them to the local hierarchy.
>
> -Mark
>
> > -----Original Message-----
> > From: Nancy [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, February 10, 2003 6:24 PM
> > To: 'Log4J Users List'
> > Subject: Urgent---Help please
> >
> >
> > Hi, all:
> >
> > The following problem has stopped me here for a while.
> > PLEASE, please help me out....
> >
> > I use SocketHubAppender to send LoggingEvent objects to a
> > remote swing application. In the javadoc of log4j, it says
> > SocketHubAppender "Sends LoggingEvent objects to a set of
> > remote log servers, usually a SocketNodes. ". How to use
> > SocketNode to recieve the LoggingEvent? Could someone give me
> > an example or a hint? I searched on the web for a while, but
> > it seems that I can't find an example relating to this.
> >
> > What I want to accomplish is to recieve LoggingEvent and
> > handle it in the swing application. The problem I am having
> > now is I don't know how to recieve the LoggingEvent in the
> > swing application. Please help me!!!. This is really URGENT.
> >
> > The javadoc says " ...usually a SocketNodes". So I guess it
> > may or may not need SocketNode to recieve the LoggingEvent. I
> > don't know how to receive the LoggingEvent with or without
> > SocketNode. I don't care using or not using SocketNode, as
> > long as this problem can be solved and I can proceed with the
> > project. Guys, please help me!!!
> >
> > Thanks so much for your guys help. I appreciate it.
> >
> > Regards,
> > Nancy
> >
>
> ---------------------------------------------------------------------
> 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]

Reply via email to