[
https://issues.apache.org/jira/browse/LOG4J2-3455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17515074#comment-17515074
]
Pooja Pandey edited comment on LOG4J2-3455 at 3/31/22, 4:49 AM:
----------------------------------------------------------------
Hi [~mattsicker],
Thank you for your response!!
Actually to achieve our functionality we are overriding getEffectiveLevel() in
our CustomLogger as below, where we have a concept of General Logger along with
various other various loggers for performance and diagnostics(Sample code is
captured in attached CustomLogger.java file). In our application we have a
requirement to update threshold level only for GeneralLogger. I think with
log4j1.x bridge, the issue could be fixed only if log4j1.x bridge invokes
getEffectiveLevel() as it used to happen in log4j1.x. Currently we could
achieve this with a workaround in our application where we get logger as per
log4j2.x API and set/clear threshold as per log4j2.x API.
@Override
public Level getEffectiveLevel()
{ Level configuredLevel = super.getEffectiveLevel(); if (!isGeneralLogger)
return configuredLevel; Level currLevel = myLevel.get(); if (currLevel == null)
return configuredLevel; if (configuredLevel == null) return currLevel; if
(currLevel.isGreaterOrEqual(configuredLevel)) return configuredLevel; return
currLevel; }
was (Author: JIRAUSER285751):
Hi [~mattsicker],
Actually to achieve our functionality we are overriding getEffectiveLevel() in
our CustomLogger as below, where we have a concept of General Logger along with
various other various loggers for performance and diagnostics(Sample code is
captured in attached CustomLogger.java file). In our application we have a
requirement to update threshold level only for GeneralLogger. I think with
log4j1.x bridge, the issue could be fixed only if log4j1.x bridge invokes
getEffectiveLevel() as it used to happen in log4j1.x. Currently we could
achieve this with a workaround in our application where we get logger as per
log4j2.x API and set/clear threshold as per log4j2.x API.
@Override
public Level getEffectiveLevel() {
Level configuredLevel = super.getEffectiveLevel();
if (!isGeneralLogger)
return configuredLevel;
Level currLevel = myLevel.get();
if (currLevel == null)
return configuredLevel;
if (configuredLevel == null)
return currLevel;
if (currLevel.isGreaterOrEqual(configuredLevel))
return configuredLevel;
return currLevel;
}
> Log4j 1.x 2.17.2 bridge - Thread specific Log Level Threshold doesn't work
> --------------------------------------------------------------------------
>
> Key: LOG4J2-3455
> URL: https://issues.apache.org/jira/browse/LOG4J2-3455
> Project: Log4j 2
> Issue Type: Bug
> Affects Versions: 2.17.2
> Reporter: Pooja Pandey
> Priority: Major
> Attachments: CustomLogger.java, CustomLoggerFactory.java,
> CustomMultiProcessRollingAppender.java, ThreadLevelLogThresholdTest.java,
> customlog.properties
>
>
> In our application we have migrated from log4j1.x to log4j1.x 2.17.2 bridge.
> With bridge 2.17.2/2.17.3-SNAPSHOT, thread specific log level threshold
> doesn't work which used to work earlier with log4j1.x. We had achieved this
> feature by overriding getEffectiveLevel(), but now this doesn't work anymore
> with log4j1.x bridge since the method getEffectiveLevel() is not getting
> invoked to set effective level.
>
> For reference, Java class files for Custom Logger, Custom Multiprocess
> Rolling Appender and Test program are attached along with cutom log4j
> properties
> file.[^CustomLogger.java][^customlog.properties][^ThreadLevelLogThresholdTest.java]
--
This message was sent by Atlassian Jira
(v8.20.1#820001)