logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Jaton <benjamin.ja...@gmail.com>
Subject Log4j2 set log level, cascade
Date Tue, 20 Oct 2015 22:13:36 GMT

Here is a simple configuration:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
*    <Logger name="com.foo.Bar" level="trace">*
      <AppenderRef ref="Console"/>
*    <Logger name="com.foo.Test" level="trace">*
      <AppenderRef ref="Console"/>
*    <Root level="error">*
      <AppenderRef ref="Console"/>

I am trying to programmatically set the log level of "com.rli", but I can't
find the Loggers until they are used:

"/tmp/test.xml");LogManager.getLogger("com.foo.Test");LoggerContext ctx =
(LoggerContext) LogManager.getContext(false);Configuration conf =
ctx.getConfiguration();for (Logger l : ctx.getLoggers()) {    LoggerConfig
config = conf.getLoggerConfig(l.getName());    System.out.println("Found
logger " + l.getName());}*
This will only show the com.foo.Test Logger because I created it just
before, but it will not find com.rli.Bar.
How can I get ALL the loggers, so that I can then set their log level?

Note that setting directly the log level of "com.rli" will not work because
what is defined for com.rli.Bar in the conf file will take precedence.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message