I'm currently working on a maven application that uses log4j and I want to be able to output all log levels to the console. I've configured as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="ERROR">
<Appenders>
<Console name="Console" target="SYSTEM_OUT" level="TRACE">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%7pid] %-5p --- myapp %-42.42c{1.} : %m%n" />
<LevelRangeFilter maxLevel="ALL" onMatch="ACCEPT" onMismatch="DENY"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<!-- Console can still output logs from higher log levels. -->
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
The I have a simple rest call that outputs each level to the console.
@RequestMapping(value = "/ping", method = RequestMethod.GET)
public ResponseEntity<?> processPing() throws Exception {
log.trace("trace");
log.debug("debug");
log.info("info");
log.warn("warn");
log.error("error");
return new ResponseEntity<>(HttpStatus.OK);
}
For the output I get everything except trace. When I change the LevelRangeFilter maxlevel value I get get the expected output but not when I set it to trace or all.
I've been up able to get trace to output. I've tried changing the root logger level, creating a custom logger, and removing the levelRangeFilter completely. None of it has worked.
Update: I found that if I call log.isTraceEnabled() it returns false. I'm currently trying to figure out how to enable it.