Well been doing that already.
Lets start with the basics
What is the syntax for configuring multiple loggers using an xml file?
If I use log4j.xml or log4j.properties I can configure one logger with code
straight from a tutorial...
org.apache.log4j.Logger conLogger = Logger.getLogger(BaseConfig.class);
Using this as a model I would think I would want
org.apache.log4j.Logger qryLogger = Logger.getLogger(BaseConfig.class);
org.apache.log4j.Logger lgLogger = Logger.getLogger(BaseConfig.class);
org.apache.log4j.Logger exLogger = Logger.getLogger(BaseConfig.class);
Yet if I use this construct, even if I set loggers in the xml file, the last
defined file will write console output to its log.
So it seems to me that instead of basing a logger on a class, I need to base a
logger on a unique xml file.
I can use
URL url = Loader.getResource("conLogger.xml");
DOMConfigurator.configure(url);
again from the same tutorial.. but it only works with 1 xml file.
So if I am limited to 1 xml file how do I configure separate loggers and
appenders in 1 xml file or is there a way I can have 4 separate xml files with
a
unique logger and appender for each?
--Refr inn gra
"Wars are to be won with swords and spears,
not with rice and salt." -- Uesugi Kenshin
________________________________
From: Jacob Kjome <[email protected]>
To: Log4J Users List <[email protected]>
Sent: Wed, December 8, 2010 11:12:08 AM
Subject: Re: Log4j with multiple files converting to xml
I suggest that you take a crack at the configuration yourself. If you still
have questions, post it and we can help you tweak it.
Jake
On Wed, 8 Dec 2010 08:16:44 -0800 (PST)
Refr Bruhl <[email protected]> wrote:
>
> Greetings
>
> I tried searching for this on the mail archives link, the link seems to be
>changed.
>
> My goal:
> I have 4 files for logging. ConLogger -> logs to console, lgLogger -> logs to
> a
>log file, qryLogger that logs to a log file, delLogger that logs to a log
>file,
>and exLogger that logs to a log file
>
> lgLogger logs generall aplication activity. I have used addAppender to ensure
>everything logged to the console is also logged to lgLogger
> qryLogger logs nothing but query information
> exLogger logs all exception errors
>
> All 4 of these files can support debug thru fatal entries.
>
> I have used this same pattern in several "batch" type jobs for about 4 years
>now.
>
> These files are configured in the primary java class.
>
> What I want to do is change the configuration from "hard" coding these log
>files in the app to using xml files for configuration.
>
>
> The problem I am running into is it seems when using xml or property files
>log4j makes the assumption of only one logger with multiple appenders per xml
>file. I want or think I want 4 distinct loggers with each having a separate
>appender.
>
> Is this correct? Has anyone else tried to do something similar with log4j?
> Any
>idea on how to achieve this?
>
>
> Thanks!
>
>
> --Refr inn gra
>
>
> "Wars are to be won with swords and spears, not with rice and salt." --
> Uesugi
>Kenshin
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]