You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Piotr Karwasz (Jira)" <ji...@apache.org> on 2022/08/30 21:43:00 UTC
[jira] [Commented] (LOG4J2-3584) StatusLogger doesn't honor `log4j2.StatusLogger.DateFormat` property when status level is set
[ https://issues.apache.org/jira/browse/LOG4J2-3584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17598084#comment-17598084 ]
Piotr Karwasz commented on LOG4J2-3584:
---------------------------------------
I think we should reimplement {{StatusConsoleListener}} to always use a {{SimpleLogger}}.
Moreover since a {{StatusConsoleListener}} is required, (cf. [StatusConfiguration|https://github.com/apache/logging-log4j2/blob/release-2.x/log4j-core/src/main/java/org/apache/logging/log4j/core/config/status/StatusConfiguration.java]), we could introduce a property with the FQCN of the main status listener. This has some applications: e.g. in the JUnit tests the output of the {{StatusConsoleListener}} clutters the output. I had to use some dirty hacks (cf. [Log4j2LauncherSessionListener|https://github.com/apache/logging-log4j2/blob/parallel-tests/log4j-api-test/src/main/java/org/apache/logging/log4j/test/junit/Log4j2LauncherSessionListener.java]) to replace it with a per-test status listener.
> StatusLogger doesn't honor `log4j2.StatusLogger.DateFormat` property when status level is set
> ---------------------------------------------------------------------------------------------
>
> Key: LOG4J2-3584
> URL: https://issues.apache.org/jira/browse/LOG4J2-3584
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Reporter: Volkan Yazici
> Priority: Major
> Fix For: 2.19.0
>
>
> I think {{StatusLogger}} doesn't honor {{log4j2.StatusLogger.DateFormat}} property, when configuration has a status level set. That is, in the following {{StatusLogger}} block:
> {code}
> public void logMessage(final String fqcn, final Level level, final Marker marker, final Message msg,
> final Throwable t) {
> // ...
> // LOG4J2-1813 if system property "log4j2.debug" is defined, all status logging is enabled
> if (isDebugPropertyEnabled() || (listeners.size() <= 0)) {
> logger.logMessage(fqcn, level, marker, msg, t);
> } else {
> for (final StatusListener listener : listeners) {
> if (data.getLevel().isMoreSpecificThan(listener.getStatusLevel())) {
> listener.log(data);
> }
> }
> }
> }
> {code}
> When {{status="trace"}} is set in {{log4j2.xml}}, {{else}} block kicks in. There the following {{StatusConsoleListener}} method gets called:
> {code}
> public void log(final StatusData data) {
> if (!filtered(data)) {
> stream.println(data.getFormattedStatus());
> }
> }
> {code}
> There {{StatusData#getFormattedStatus()}} completely ignores {{log4j2.StatusLogger.DateFormat}} while formatting the date.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)