Although you can determine at what level each class is logged in log4j 1, for example:
<logger name="org.springframework.security"> <level value="ERROR"/> </logger>
Unable to fine tune it.
To get more precise control over logging, you need to update log4j 2.
In Log4j 2 you can use filters:
http://logging.apache.org/log4j/2.x/manual/filters.html
here is a fragment of the configuration using a regular expression filter:
<?xml version="1.0" encoding="UTF-8"?> <configuration status="warn" name="MyApp" packages=""> <appenders> <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/app-%d{MM-dd-yyyy}.log.gz"> <RegexFilter regex=".* test .*" onMatch="ACCEPT" onMismatch="DENY"/> <PatternLayout> <pattern>%d %p %C{1.} [%t] %m%n</pattern> </PatternLayout> <TimeBasedTriggeringPolicy /> </RollingFile> </appenders> <loggers> <root level="error"> <appender-ref ref="RollingFile"/> </root> </loggers> </configuration>
Brian source share