• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

log4j - SocketAppender - java.io.EOFException

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm currently looking into doing asynchronous remote logging with log4j.
I've successfully implemented my AsyncAppender and tested it with the console appender, and now I'm trying to implement it with the SocketAppender, but I'm getting this error in the server log file:



Here is my config file on the client:



Here is my client test code:



Now on the server side I'm running a very simple console app that's really just instanciating the log4j SimpleSocketServer implementation:



With the following config file associated to it:



Since log4j is very verbose, from the Eclipse console I've been able to verify that both config files, client and server, get picked up correctly.

I did find something interesting Googling around:

SimpleSocketServer BufferedIO issue

But that didn't help very much. Tried the suggestion and still getting the same error message.

Anyone successfully implemented AsyncAppender + SocketAppender with SimpleSocketServer by any chance?

Any idea if this is a "user" error or a problem with the SimpleSocketServer implementation? Any other SocketNode server implementation I could try out there?
 
yann luppo
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still couldn't find anything on the web and no one actually replied to my post, so I'm guessing either it's a bug, or no one is using the SocketAppender w/ the SimpleSocketServer (unlikely but who knows...)

Anyway I've replaced the SocketAppender with the SocketHubAppender in my AsyncAppender, and it seems to work. The only thing is it actually works backward... The machine with the AsyncAppender and the SocketHubAppender now buffers all the logs on a port and if something connects on that port then it gets the logs, if nothing connects the older logs are pushed out of the buffer.

In a nutshell my client app (which really behaves as a server now) has the following config file:



My client code is very simple:



My server is barebone for now. I'm guessing you could implement log4j to it pretty easily, the same way it's done for the client, but for what we need to do, we might just go custom from the raw data in the LoggingEvent object. The code looks like this:



Hope this helps whoever is encountering the same type of issues, or like me has spent way too much time trying to figure out how to use the SocketAppender or the SocketHubAppender.

Looking forward to test the SocketAppender in Log4j 2.0.

Cheers,
Yann
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting a solution Yann. I'll confess I've never tried doing that with Log4J so I couldn't help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic