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:
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?
posted 10 years ago
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.