• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

log4j - SocketAppender - java.io.EOFException

Posts: 26
  • Mark post as helpful
  • send pies
  • 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
Posts: 26
  • Mark post as helpful
  • send pies
  • 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.

Posts: 3281
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!