Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-541

Allow all lookup types in DynamicThresholdFilter

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: None
    • Component/s: Filters
    • Labels:
    • Environment:

      Windows 7
      Java 6

      Description

      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.

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

      Alternatively, allow the threshold filter to be substituted with a runtime lookup value.

      log4j2.json snippet
       "root":{
            "AppenderRef":{
               "ref":"Console Appender",
               "ThresholdFilter":{
                  "level":"$${map:log.console.level}",
                  "onMatch":"ACCEPT",
                  "onMisMatch":"DENY"
               }
            }
         }
      

      The above will allow the developer to customise the log level at runtime across various loggers, appenders etc.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jpretorius James Pretorius
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: