logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gemoets, Darren" <Darren.Gemo...@commerceone.com>
Subject Configuring log4j from multiple configuration files
Date Tue, 12 Mar 2002 00:01:39 GMT
Hello all.  I'm a new log4j user and ran into a problem setting up my
configuration from multiple (two) files.  I was wondering if anyone had
any thoughts/suggestions.

What I'd like to do is set "default" configuration from one file (preferably
referred to by -Dlog4j.configuration), and then read additional
configuration
from another properties file which overrides the defaults.  The
JavaDoc for PropertyConfigurator.doConfigure(String configFileName,
Hierarchy hierarchy), says, "Read configuration from a file. The existing
configuration is not cleared nor reset."  Therefore, it looked like I could
do something like:

  PropertyConfigurator props = new PropertyConfigurator();
  // load default configuration
  props.doConfigure("defaultConfig.txt", Category.getRoot().getHierarchy());
  // load (optional) configuration which overrides specific fields of
default
  props.doConfigure("overrideConfig.txt",
Category.getRoot().getHierarchy());

So if my "defaultConfig.txt" looked like
  # Set root category priority to ERROR and its only appender to Console.
  log4j.rootCategory=ERROR, Console
  # Console appender is set to be a ConsoleAppender.
  log4j.appender.Console=org.apache.log4j.ConsoleAppender
  # Console uses PatternLayout.
  log4j.appender.Console.layout=org.apache.log4j.PatternLayout
  log4j.appender.Console.layout.ConversionPattern=%-4r [%t] %-5p %c{2} %x -
%m%n

then I could simply add
  log4j.rootCategory=DEBUG, Console

to change the default logging from ERROR to DEBUG.  Because the existing
configuration is neither cleared nor reset by doConfigure(), I figured I'd
just be adding/changing existing config properties.  However, it doesn't
seem
to work that way.  It keeps reading the first file, then trying to read the
second file and failing saying no appenders could be found for root, as if
it cleared/reset the default configuration initially read.

Thanks in advance for any help/suggestions!  I'm not on the log4j-user
group,
so please reply to darren.gemoets@commerceone.com (and/or to the group).

Regards,
----------------
Darren Gemoets
Aquilent (formerly Commerce One e-Government Solutions)
darren.gemoets@commerceone.com
301-496-1796

--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message