Loging a distributed application ? any patterns/framework available?

Hi all,

I want to write a logging mechanism to an distributed application using Log4j such that I need to get the logs of the whole application in a single file.

Currently I have logged that application that runs in a single machine.but I want the log mechanism to work when the application gets distribured.

The application runs in Tomcat.

How do I achive that?

Please help me

[414 byte] By [sudarsona] at [2007-10-2 0:37:42]
# 1

There is a simple way to do it. Make one class accept all the logging messages, call it the DistributedLogger. Make sure DistributedLogger implements the distributed Singleton pattern. There are lots of examples of this using google.

http://www2-data.informatik.unibw-muenchen.de/People/ansgar/dito/patterns/singleton.html

// old way

public void myMethod() {

logger.error(...);

}

->

// new way

public void myMethod() {

DistributedLogger.getInstance().error(...);

}

jvaudrya at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

Thanks a lot for your reply!!!

Please help me on how to make the distributed logger Object visible to other so that they can write on it.

Currently I have created a logger object and access that object in all the java programs.

now if the application goes distributed how will that Happen?

Please help me out of this Issue by letting me know the URL of some web pages that gives some samples.

Thanks and waiting for your reply.

sudarsona at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 3

Thanks a lot for your reply!!!

Please help me on how to make the distributed logger Object visible to other so that they can write on it.

Currently I have created a logger object and access that object in all the java programs.

now if the application goes distributed how will that Happen?

Please help me out of this Issue by letting me know the URL of some web pages that gives some samples.

Thanks and waiting for your reply.

sudarsona at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
Sorry, you need to go back to school and learn more. Take a course on distributed computing. It's just not that easy to get a URL and go.
jvaudrya at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 5
Doesn't log4j have some classes which already help with this? (SocketAppender / JDBCAppender)
jvaudrya at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
Cool, didn't know that existed. Looking at the SocketAppender javadoc, it seems like that's what the OP wants.
jvaudrya at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 7

I prefer a queue appender. That way the app can continue to operate even if the logging database goes down. Write the message to the queue, have a MessageListener take it off and insert it into the database.

Log4J comes with a JMSAppender that uses Topic; it's an exercise to write it to use a Queue. It's an elegant design.

%

duffymoa at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...
# 8
> Log4J comes with a JMSAppender that uses Topic; it's an exercise to write it to use a Queue. It's an elegant designI didn't know that existed (I dont use Log4J for various reasons), but thats very cool.
duffymoa at 2007-7-15 16:52:21 > top of Java-index,Other Topics,Patterns & OO Design...