Log4j 2
  1. Log4j 2
  2. LOG4J2-464

JSON Syntax: LoggerConfig - multiple AppenderRef entries

    Details

      Description

      How does one assign multiple AppenderRef entries to a logger when using JSON syntax? I've tried numerous formats but none of them appear to work. Exampe below.

      "loggers": {
      "logger": [
      {
      "name": "helloWorld",
      "level": "info",
      "additivity": "true",
      "AppenderRef": [

      { "ref": "File Routing Appender" }

      ,

      { "ref": "Database Routing Appender" }

      ]
      }
      ],
      "root": {
      "level": "info",
      "AppenderRef":

      { "ref": "Console Appender" }

      }
      }

      2013-12-11 08:32:07,012 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="true", level="info", name="helloWorld", includeLocation="null", AppenderRef={}, Properties={}, Configuration(Hello World Config), null)

      The only way I've been able to hack this (up to a maximum of two AppenderRefs) is to use the appender-ref alias in conjunction with AppenderRef e.g.:
      "loggers": {
      "logger": [

      {
      "name": "helloWorld",
      "level": "info",
      "additivity": "true",
      "AppenderRef":

      { "ref":"File Routing Appender" }

      ,
      "appender-ref":

      { "ref":"Database Routing Appender" }

      }
      ],
      "root": {
      "level": "info",
      "AppenderRef":

      { "ref": "Console Appender" }

      }
      }
      2013-12-11 08:51:54,977 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="true", level="info", name="helloWorld", includeLocation="null", AppenderRef=

      {File Routing Appender, Database Routing Appender}

      , Properties={}, Configuration(Hello World Config), null)

        Activity

        Hide
        James Pretorius added a comment -

        Thank you

        Show
        James Pretorius added a comment - Thank you
        Hide
        Ralph Goers added a comment -

        Fixed in revision 1553789. You can now specifiy

        "AppenderRef": [{ "ref": "LIST1", "level": "warn" }, {"ref": "LIST2", "level": "debug"}]
        

        in addition to

        "AppenderRef": {"ref": "LIST1", "level": "trace"}
        

        Please verify and close.

        Show
        Ralph Goers added a comment - Fixed in revision 1553789. You can now specifiy "AppenderRef" : [{ "ref" : "LIST1" , "level" : "warn" }, { "ref" : "LIST2" , "level" : "debug" }] in addition to "AppenderRef" : { "ref" : "LIST1" , "level" : "trace" } Please verify and close.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development