Skip to content

LevelRangeFilter not working properly with INFO set as minLevel #1495

Closed
@NA-Dev

Description

@NA-Dev

Description

I have an appender with a LevelRangeFilter. If I set minLevel="ERROR" it works properly logging only ERROR and above. If I instead set minLevel="INFO" nothing logs at all. If I remove the LevelRangeFilter line altogether, it logs every level properly. So there is some bug with the LevelRangeFilter going on here.

Configuration

Version: [Log4j version] 2.20.0

Operating system: [OS and version] Windows 10 and Ubuntu 22.04

JDK: [JDK distribution and version] JDK 16.0.1

Logs

No log4j errors log and it is using my config file properly other than this bug

Reproduction

Here is my config file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>

<Configuration status="WARN" monitorInterval="30">
	<Properties>
		<Property name="logger_path" value="log" />
		<Property name="pattern" value="%d{yyyy-MM-dd HH:mm} [%highlight{%-6level}{FATAL=bg_red, ERROR=red, WARN=yellow, INFO=white, DEBUG=cyan}] %C{-3}: %M (%F:%L) - %m%n" />
		<Property name="pattern_teams" value="${hostName}: [%level] %C{-3}: %M (%F:%L) BEGIN_MESSAGE %m BEGIN_EXCEPTION %ex" />
	</Properties>
	<ThresholdFilter level="debug"/>
    <Appenders>
	    <Console name="Console" target="SYSTEM_OUT" follow="true" ignoreExceptions="false">           
	         <PatternLayout pattern="${pattern}%ex" disableAnsi="false"/>
        </Console> 
 
        <RollingFile name="MyLog" fileName="${logger_path}/${hostName}_java_errors.log" filePattern="${logger_path}/$${date:yyyy-MM}/${hostName}_java_errors_%d{MM-dd-yyyy}-%i.log.gz" ignoreExceptions="false" >
            <PatternLayout pattern="${pattern}%ex" disableAnsi="true" />
            <Filters>
	            <LevelRangeFilter minLevel="INFO"/>      
	            <BurstFilter rate="1" maxBurst="3"/>
	        </Filters>
	        <Policies>
	      		<TimeBasedTriggeringPolicy />            
	      		<SizeBasedTriggeringPolicy size="250 MB"/> 
  		    </Policies>
  		    <DefaultRolloverStrategy max="20"/>
        </RollingFile>
 	</Appenders>
 	
    <Loggers>     
        <Root level="info">
	        <AppenderRef ref="Console"/>
            <AppenderRef ref="MyLog"/>
        </Root>
    </Loggers>
    
</Configuration>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions