This discussion is archived
3 Replies Latest reply: Apr 7, 2007 7:09 AM by 807597 RSS

Logging a distributed application using log4j socket appenders???

807596 Newbie
Currently Being Moderated
Basically My application is distributed across two or more tomcat servers running in multiple machines.And I get a log4j logs in the respective machines.

But I want a consolidated log message in a single machine.
How do i get that done??

Any samples?? Any clues??
Any specific technoliges??
  • 1. Re: Logging a distributed application using log4j socket appenders???
    807596 Newbie
    Currently Being Moderated
    log4j can be directed to any output stream... including a Socket connected to another pc.

    you still need to write a small application that receives the log4j data and writes it to a log file.
  • 2. Re: Logging a distributed application using log4j socket appenders???
    807596 Newbie
    Currently Being Moderated
    You just need to run a log4j socket server java process on the logging server ( where all of your logs will be written )

    java org.apache.log4j.net.SocketServer port configFile configDir


    http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SocketServer.html

    Then on each of your respective servers you need to setup you log4j.properties or xml configuration to point to the logging server with a SocketAppender

    http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SocketAppender.html

    I have not done this myself, but it looks straight forward, and I don't think it requires any custom development. You will just have an extra logging server to manage.
  • 3. Re: Logging a distributed application using log4j socket appenders???
    807597 Newbie
    Currently Being Moderated
    Hi All. I have created a simple guide to setting up a log4j socket server.

    Log4j has a class called org.apache.log4j.net.SocketServer. This class is capable of receiving log messages over a socket and processing them through any of the supported Log4j Appenders. In my example I show how to use the SMTPAppender, and I setup a log4j socket server on my unix box to listen for log messages and process them. All of your clients, or tomcat servers in your case, could then send their messages to the central log4j socket server.

    Its pretty easy to do, checkout my writeup at:
    http://timarcher.com/?q=node/10