[
https://issues.apache.org/jira/browse/LOG4J2-541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13933440#comment-13933440
]
Ralph Goers commented on LOG4J2-541:
------------------------------------
If you want to enhance the DynamicThresholdFilter to support lookups it also
has to continue to support being configured with an MDC key. As I recall the
problem I ran into was that all the filter methods currently call filter(Level
level). When you add the ability to filter on a lookup you need a log event.
This means that all the filter methods that accept individual parameters would
need to construct a LogEvent to pass to the Lookup, which is unacceptable, or
Lookup would need to be modified to add a method that accepts individual
parameters in addition to the existing method that accepts a LogEvent.
I do not understand why you would use a lookup on both the key and the level.
The idea of this filter is that a given value has a specific level.
> Allow all lookup types in DynamicThresholdFilter
> ------------------------------------------------
>
> Key: LOG4J2-541
> URL: https://issues.apache.org/jira/browse/LOG4J2-541
> Project: Log4j 2
> Issue Type: Improvement
> Components: Filters
> Affects Versions: 2.0-rc1
> Environment: Windows 7
> Java 6
> Reporter: James Pretorius
> Labels: features
>
> Currently the DynamicThresholdFilter only supports key values pairs in the
> ThreadContextMap. It would be good to see this expanded to include all log4j2
> lookups.
> In the below example the threshold level would be stored in a map value
> substituted at runtime.
> {code:javascript|title=log4j2.json snippet}
> "root":{
> "AppenderRef":{
> "ref":"Console Appender",
> "DynamicThresholdFilter":{
> "defaultThreshold":"debug",
> "key":"$${map:log.console.level}",
> "onMatch":"ACCEPT",
> "onMisMatch":"DENY",
> "keyValuePair":[
> {
> "key":"off",
> "value":"off"
> },
> {
> "key":"fatal",
> "value":"fatal"
> },
> {
> "key":"error",
> "value":"error"
> },
> {
> "key":"warn",
> "value":"warn"
> },
> {
> "key":"info",
> "value":"info"
> },
> {
> "key":"debug",
> "value":"debug"
> },
> {
> "key":"trace",
> "value":"trace"
> }
> ]
> }
> }
> }
> {code}
> Alternatively, allow the threshold filter to be substituted with a runtime
> lookup value.
> {code:javascript|title=log4j2.json snippet}
> "root":{
> "AppenderRef":{
> "ref":"Console Appender",
> "ThresholdFilter":{
> "level":"$${map:log.console.level}",
> "onMatch":"ACCEPT",
> "onMisMatch":"DENY"
> }
> }
> }
> {code}
> The above will allow the developer to customise the log level at runtime
> across various loggers, appenders etc.
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]