'Log4j2 Control What is Being Logged

we recently migrated from Log4j 1.2 to Log4j 2.17.2 (Latest). However, with DEBUG level or not how do I control what is being logged? The system is deployed in a IBM WebSphere Profile version 9.0 Network Deployment. I see IBM logs from IBM jars and I think they are from the WAS Server. How do I disable/control this?

Example unnecessary logs:

[com.ibm.kc.Instance] DEBUG LiveRefresh134 - Refreshing the configuration and content... [com.ibm.kc.utils.Monitors$FileMonitor] DEBUG LiveRefresh134 - File monitor refreshed for 25200 time(s) w/o hit.

Log4j2.xml

<Configuration>
    <Appenders>
    <Console name="CONSOLE" target="SYSTEM_OUT">
        <PatternLayout pattern="%d %-4r [%c] %-5p %t - %m%n"/>
    </Console>
        
    <RollingFile name="FILE" filename="./logs/SystemLogs.log">
        <PatternLayout pattern="%d %-4r [%c] %-5p %t - %m%n"/>
        <Policies>
            <SizeBasedTriggeringPolicy size="1000 KB"/>
        </Policies>
        <DirectWriteRolloverStrategy maxFiles="5"/>
    </RollingFile>
    
    </Appenders>
    
    <Loggers>
    <Logger name="org.springframework" additivity="false" level="ERROR"/>
    
    <Root level="DEBUG">
        <AppenderRef ref="CONSOLE" />
        <AppenderRef ref="FILE" />
    </Root>
    
  </Loggers>
</Configuration>

Jars used: Log4j-core-2.17.2.jar Log4j-api-2.17.2.jar



Solution 1:[1]

You can control what is being logged by assigning the package a certain level like ERROR.

<Logger name="com.ibm.kc" additivity="false" level="ERROR"/>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ice