logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mansour <mansour77+li...@ownmail.net>
Subject Logger.getRootLogger() ?? is't static with respect to the JVM ?
Date Sat, 16 Sep 2006 22:42:08 GMT
Hello every body:
I am having some difficulties working with log4j, and I need some help 
from some one.
I am writing a client/server application, in some way it can be compared 
with a chat client, where two or more users connect to the server 
through an applet.
Now the applets uses classes from packages I wrote. The classes logges 
messages to no where (no logger is configured in them) I left the 
configuration for the main class, so that I can reuse those classes 
elsewhere. I am using a simple appender that I wrote, to display the 
logs in a JFrame.
The problem is I am getting the logs from each applet displayed in it's 
own log JFrame and in the other one!!
I am testing this on my machine, now both chat programs (applets) 
connect to the server. The first one logs the messages to both Frames !! 
And the second one does the same.

At the begining of each applet I used this:
logger = Logger.getLogger(this.getClass());
Logger.getRootLogger().addAppender(new FrameAppender(this,"Controller 

from what I understand, Logger.getRootLogger() is a static method, 
therefore the logger returned by it ( Logger.getRootLogger() ) is 
static, but static means for each JVM. In other words, both applets run 
in a separate JVMs, and there should be nothing shared !!!

Now, what ever was the reason, how do I get around this ??? Let's say My 
main class is called Chat.java , and it uses another class CustomSocket.java
What i would do in CustomSocket.java, is instantiate an object of Logger 
through  Logger.getLogger(this.getClass()), and logs  my messages 
normally. Then the application that  uses CustomSocket has to configure 
the logger (apender, Level ,....etc). How do I achive this. Please note 
that I am only newbie, and I am not looking to use configuration files. 
Just doing very basic configuration.
If you need any more info about this problem, just please let me know, I 
've included what I think is relevant.
Thank you.

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message