You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Maciej Gawinecki <mg...@gmail.com> on 2006/09/13 10:27:52 UTC

static logger and instances with names

Hi!

I'm developing distributed application with of 5 agents, where 2 agents
are instances of class X and 3 agents - of class Y. Each agent has
unique name. I would like, that loggers contained reported also the
names of agents, but there, in fact, loggers are static and thus
associated with classes, not instances.

Has anyone of you meet similar approach ?

Best,
Maciej




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


Re: static logger and instances with names

Posted by Boris Unckel <bo...@gmx.net>.
Hello Maciej,

first I think this should go to the users list, dev is for log4j development itself.
-------- Original-Nachricht --------
Datum: Wed, 13 Sep 2006 10:27:52 +0200
Von: Maciej Gawinecki <mg...@gmail.com>
An: log4j-dev@logging.apache.org
Betreff: static logger and instances with names

> I'm developing distributed application with of 5 agents, where 2 agents
> are instances of class X and 3 agents - of class Y. Each agent has
> unique name. I would like, that loggers contained reported also the
> names of agents, but there, in fact, loggers are static and thus
> associated with classes, not instances.
> 
> Has anyone of you meet similar approach ?
Static Loggers (independent from the library or logging wrapper) are a problem, have a look at:
http://wiki.apache.org/jakarta-commons/Logging/StaticLog

You could have something like this:

public class Y {

private Logger log;

public Y(final String instancename) {
 this.log = Logger.getLogger(instancename);
}
}

Regards
Boris

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