logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-441) logger level configuration does not work correct
Date Wed, 06 Nov 2013 23:06:17 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-441?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Remko Popma updated LOG4J2-441:
-------------------------------

    Description: 
Configuring the loglevel in the logger does not work in combination with configuring the loglevel
at the appender-refs. I analyzed this with the beta9. See the table which lists various loglevel
configurations for the 3 loggers. The column format for the table is:
Column 1-6 are the logger with their level config (level@logger1, level@appender-ref)(level@logger2,
level@appender-ref)(level@logger3, level@appender-ref)
Column 7 is the actual output
Column 8 is the expected Output
I also attached the test which can be taken to reproduce the according behaviour. 

|1|2|3|4|5|6|7|8|
||level 1 logger||level 1 appender-ref||level 2 logger||level 2 appender-ref||level 3 logger
||level 3 appender-ref||actual output||expected output||
|-|-|-|info|debug|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|-|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|info|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|fatal|fatal|info|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|info|info|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|debug|info|info| |debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger1: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|info|debug|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|info|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|trace|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger1: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|-|-|info|info|fatal|debug|-|Logger2: info logger
Logger2: warning logger|
|-|-|info|info|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|-|info|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|info|-|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger2: trace logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|

Here is the log4j2.xml:
{code:xml}
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
	<appenders>
		<console name="TestConsole0">
			<PatternLayout pattern="RootLogger: %msg%n"/>
		</console>
		<console name="TestConsole1">
			<PatternLayout pattern="Logger1: %msg%n"/>
		</console>
		<console name="TestConsole2">
			<PatternLayout pattern="Logger2: %msg%n"/>
		</console>
		<console name="TestConsole3">
			<PatternLayout pattern="Logger3: %msg%n"/>
		</console>
	</appenders>
	
	<loggers>
		<logger name="" >
			<appender-ref ref="TestConsole1" />
		</logger>
		
		<logger name ="com.log4jtest" level="info">
			<appender-ref ref="TestConsole2" level="info"/>
		</logger>
		
		<logger name ="com.log4jtest.test" level="fatal">
			<appender-ref ref="TestConsole3" level="debug"/>
		</logger>
		
		<root level="error">
			<appender-ref ref="TestConsole0" level="error"/>
		</root>
	</loggers>
</configuration>
{code}

And here are the logging calls:
{code:title=Log4j2LogLevelTest.java|borderStyle=solid}
package com.log4jtest.test;

import static org.junit.Assert.*;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

public class Log4j2LogLevelTest {

	private static final Logger logger = LogManager.getLogger(Log4j2LogLevelTest.class);
	
	@Test
	public void testLogLevel() {
		logger.info("info logger");
		logger.debug("debug logger");
		logger.warn("warning logger");
		logger.trace("trace logger");
	}

}
{code}


  was:
Configuring the loglevel in the logger does not work in combination with configuring the loglevel
at the appender-refs. I analyzed this with the beta9. See the table which lists various loglevel
configurations for the 3 loggers. The column format for the table is:
Column 1-6 are the logger with their level config (level@logger1, level@appender-ref)(level@logger2,
level@appender-ref)(level@logger3, level@appender-ref)
Column 7 is the actual output
Column 8 is the expected Output
I also attached the test which can be taken to reproduce the according behaviour. 

|1|2|3|4|5|6|7|8|
||level.1.logger||level.1.appender-ref||level.2.logger||level.2.appender-ref||level.3.logger
||level.3.appender-ref||actual output||expected output||
|-|-|-|info|debug|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|-|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|info|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|fatal|fatal|info|info|-|debug|-|Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger|
|info|info|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|debug|info|info| |debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger1: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|info|debug|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|info|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|debug|trace|info|info|-|debug|-|Logger2: info logger
Logger1: info logger
Logger3: debug logger
Logger2: debug logger
Logger1: debug logger
Logger3: warning logger
Logger2: warning logger
Logger1: warning logger|
|-|-|info|info|fatal|debug|-|Logger2: info logger
Logger2: warning logger|
|-|-|info|info|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|-|info|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|
|-|-|info|-|trace|debug|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger2: debug logger
Logger3: warning logger
Logger2: warning logger
Logger2: trace logger|Logger3: info logger
Logger2: info logger
Logger3: debug logger
Logger3: warning logger
Logger2: warning logger|

Here is the log4j2.xml:
{code:xml}
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
	<appenders>
		<console name="TestConsole0">
			<PatternLayout pattern="RootLogger: %msg%n"/>
		</console>
		<console name="TestConsole1">
			<PatternLayout pattern="Logger1: %msg%n"/>
		</console>
		<console name="TestConsole2">
			<PatternLayout pattern="Logger2: %msg%n"/>
		</console>
		<console name="TestConsole3">
			<PatternLayout pattern="Logger3: %msg%n"/>
		</console>
	</appenders>
	
	<loggers>
		<logger name="" >
			<appender-ref ref="TestConsole1" />
		</logger>
		
		<logger name ="com.log4jtest" level="info">
			<appender-ref ref="TestConsole2" level="info"/>
		</logger>
		
		<logger name ="com.log4jtest.test" level="fatal">
			<appender-ref ref="TestConsole3" level="debug"/>
		</logger>
		
		<root level="error">
			<appender-ref ref="TestConsole0" level="error"/>
		</root>
	</loggers>
</configuration>
{code}

And here are the logging calls:
{code:title=Log4j2LogLevelTest.java|borderStyle=solid}
package com.log4jtest.test;

import static org.junit.Assert.*;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;

public class Log4j2LogLevelTest {

	private static final Logger logger = LogManager.getLogger(Log4j2LogLevelTest.class);
	
	@Test
	public void testLogLevel() {
		logger.info("info logger");
		logger.debug("debug logger");
		logger.warn("warning logger");
		logger.trace("trace logger");
	}

}
{code}



Edited table: allow headers to wrap (could not see 2 right-most columns).

> logger level configuration does not work correct
> ------------------------------------------------
>
>                 Key: LOG4J2-441
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-441
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>            Reporter: Andreas Rytina
>         Attachments: log4jtest.zip
>
>
> Configuring the loglevel in the logger does not work in combination with configuring
the loglevel at the appender-refs. I analyzed this with the beta9. See the table which lists
various loglevel configurations for the 3 loggers. The column format for the table is:
> Column 1-6 are the logger with their level config (level@logger1, level@appender-ref)(level@logger2,
level@appender-ref)(level@logger3, level@appender-ref)
> Column 7 is the actual output
> Column 8 is the expected Output
> I also attached the test which can be taken to reproduce the according behaviour. 
> |1|2|3|4|5|6|7|8|
> ||level 1 logger||level 1 appender-ref||level 2 logger||level 2 appender-ref||level 3
logger ||level 3 appender-ref||actual output||expected output||
> |-|-|-|info|debug|debug|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|Logger2: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |-|-|-|info|-|debug|-|Logger2: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |-|-|info|info|-|debug|-|Logger2: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |fatal|fatal|info|info|-|debug|-|Logger2: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |info|info|info|info|-|debug|-|Logger2: info logger
> Logger1: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger1: warning logger|
> |debug|debug|info|info| |debug|-|Logger2: info logger
> Logger1: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger1: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger1: warning logger|
> |info|debug|info|info|-|debug|-|Logger2: info logger
> Logger1: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger1: warning logger|
> |debug|info|info|info|-|debug|-|Logger2: info logger
> Logger1: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger1: warning logger|
> |debug|trace|info|info|-|debug|-|Logger2: info logger
> Logger1: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger1: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger1: warning logger|
> |-|-|info|info|fatal|debug|-|Logger2: info logger
> Logger2: warning logger|
> |-|-|info|info|trace|debug|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |-|-|-|info|trace|debug|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> |-|-|info|-|trace|debug|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger2: debug logger
> Logger3: warning logger
> Logger2: warning logger
> Logger2: trace logger|Logger3: info logger
> Logger2: info logger
> Logger3: debug logger
> Logger3: warning logger
> Logger2: warning logger|
> Here is the log4j2.xml:
> {code:xml}
> <?xml version="1.0" encoding="UTF-8" ?>
> <configuration>
> 	<appenders>
> 		<console name="TestConsole0">
> 			<PatternLayout pattern="RootLogger: %msg%n"/>
> 		</console>
> 		<console name="TestConsole1">
> 			<PatternLayout pattern="Logger1: %msg%n"/>
> 		</console>
> 		<console name="TestConsole2">
> 			<PatternLayout pattern="Logger2: %msg%n"/>
> 		</console>
> 		<console name="TestConsole3">
> 			<PatternLayout pattern="Logger3: %msg%n"/>
> 		</console>
> 	</appenders>
> 	
> 	<loggers>
> 		<logger name="" >
> 			<appender-ref ref="TestConsole1" />
> 		</logger>
> 		
> 		<logger name ="com.log4jtest" level="info">
> 			<appender-ref ref="TestConsole2" level="info"/>
> 		</logger>
> 		
> 		<logger name ="com.log4jtest.test" level="fatal">
> 			<appender-ref ref="TestConsole3" level="debug"/>
> 		</logger>
> 		
> 		<root level="error">
> 			<appender-ref ref="TestConsole0" level="error"/>
> 		</root>
> 	</loggers>
> </configuration>
> {code}
> And here are the logging calls:
> {code:title=Log4j2LogLevelTest.java|borderStyle=solid}
> package com.log4jtest.test;
> import static org.junit.Assert.*;
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> import org.junit.Test;
> public class Log4j2LogLevelTest {
> 	private static final Logger logger = LogManager.getLogger(Log4j2LogLevelTest.class);
> 	
> 	@Test
> 	public void testLogLevel() {
> 		logger.info("info logger");
> 		logger.debug("debug logger");
> 		logger.warn("warning logger");
> 		logger.trace("trace logger");
> 	}
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

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


Mime
View raw message