TRACE Log Level

I know the following log levels in Log4J:

ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF 

But in some probes I found TRACE

and trace() method:

 Logger LOG = Logger.getLogger(MyClass.class); LOG.trace("Instance created of AnotherClass"); 

In my IDE method, trace() not recognized. Is this old Log4J and TRACE library just in some new one?

+6
source share
3 answers

Log4j itself does not have a TRACE level. This log level is provided by newer logging facades such as commons-logging or slf4j . These facades themselves are not registered, but are delegated to the main registration providers, such as logback or logback .

+7
source

The org.apache.log4j.Level.TRACE level was added to log4j in version 1.2.12

You need to update the version of your log4j library.

+6
source

you should mention this on log4j2-test.xml

 <Loggers> <Logger name="com.foo.Bar" level="trace"> <AppenderRef ref="Console"/> </Logger> <Root level="error"> <AppenderRef ref="Console"/> </Root> 

You must specify your log level as a trace if you want to log traces

https://logging.apache.org/log4j/2.x/manual/configuration.html#Additivity

+1
source

Source: https://habr.com/ru/post/957015/


All Articles