Naturally, but even if I set in the file: log4.loggerFactory=MyFactory
And in the code I have org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(myLogger);
I don't get the logger that my factory created. I see in debug that the
factory is called but my client code still gets a native log4j Logger and
not my own custom logger.
From what I saw in the code the reason is because log4j uses internally a
RepositorySelector that always returns the regular Logger. The LogManager
has a setter but log4j does not expose calling this setter via
configuration. This is really what I think is missing.
You can always call a code like this:
LogManager.setRepositorySelector(new RepositorySelector(){
public LoggerRepository getLoggerRepository() {
return myHierarchy;
}
}, null);
But when this is done via code and not using configuration this means every
new client needs to run this code. I am looking for a pure configurable
solution so each new client that wants to work with my Custom Logger just
needs to set the correct properties in log4j.properties.
I hope this thread is clear for every one...
Thanks.
On Thu, Apr 2, 2009 at 2:15 PM, Bender Heri hben...@ergonomics.ch wrote:
Already looked at the LoggerFactory?
Heri
-Ursprüngliche Nachricht-
Von: Yair Ogen [mailto:yairo...@gmail.com]
Gesendet: Donnerstag, 2. April 2009 10:13
An: log4j-user@logging.apache.org
Betreff: Configure custom logger from file
Hi,
I need to configure a custom Legger that extends then log4j Logger.
I want users to code: Logger.getLogger, and get the custom logger.
I know how to do this in code, but this will require every developer to
call this code.
I want to find a way to this via the log4.properties file so if all
developers use the same file their code is clean and will use the custom
logger in a transparent way.
Any ideas?
Thanks.
-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org