[
https://issues.apache.org/jira/browse/LOG4J2-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17405627#comment-17405627
]
Ralph Goers commented on LOG4J2-3151:
-------------------------------------
This is working correctly. The levels are defined as:
{code:java}
/**
* No events will be logged.
*/
OFF(0),
/**
* A severe error that will prevent the application from continuing.
*/
FATAL(100),
/**
* An error in the application, possibly recoverable.
*/
ERROR(200),
/**
* An event that might possible lead to an error.
*/
WARN(300),
/**
* An event for informational purposes.
*/
INFO(400),
/**
* A general debugging event.
*/
DEBUG(500),
/**
* A fine-grained debug message, typically capturing the flow through the
application.
*/
TRACE(600),
/**
* All events should be logged.
*/
ALL(Integer.MAX_VALUE);
{code}
Log4j only documents using FATAL, ERROR, WARN, INFO, DEBUG, & TRACE in your
application code. OFF and ALL are for use in your logging configuration file.
When used there they behave as you would expect. Because OFF has the lowest
value when used in your application there is no way to suppress it as setting
the configured to OFF will still match OFF.
So the short answer is, don't use OFF or ALL in your application code unless
you want the exact opposite of what the names imply (i.e. ALL will only be
logged when ALL is the configured value).
> Messages get logged at level OFF
> --------------------------------
>
> Key: LOG4J2-3151
> URL: https://issues.apache.org/jira/browse/LOG4J2-3151
> Project: Log4j 2
> Issue Type: Bug
> Affects Versions: 2.14.1
> Reporter: Nils Breunese
> Priority: Major
>
> I am using the following Log4j API to log messages at a configurable level:
> {code:java}
> logger.atLevel(level).log(...); {code}
> This works fine, but then a user configured the log level to be {{Level.OFF}}
> and to his surprise messages were still logged, at level {{OFF}}. This feels
> like a bug to me.
> I have created a small demo project that reproduces this behaviour at
> [https://github.com/breun/log4j-off]. This project logs these two messages:
> {code:java}
> INFO - Foo
> OFF - Foo {code}
> But I expected only the first of those two to get logged.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)