[ 
https://issues.apache.org/jira/browse/LOG4J2-541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13939273#comment-13939273
 ] 

James Pretorius commented on LOG4J2-541:
----------------------------------------

{quote}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.{quote} 

I was trying to demonstrate setting the log level at runtime using a 
substituted lookup in the config file. I had a good look around and using a 
DynamicThresholdFilter seemed to be the only out the box option that would 
allow for this as it allows for a default threshold and it allows for the 
threshold to be changed based on a runtime input value***. The only limitation 
was that the lookup was restricted to a ThreadContextMap. 

So, in summary passing the level as the key was purely to work in accordance 
with the filter functionality because from what I could tell no other out of 
the box option allowed for the functionality above.

***Possibly this is the issue here, is there a better/recommended way of 
setting the log level at runtime using a substitued lookup?





> 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]

Reply via email to