Config log4j2 with JSON Config log4j2 with JSON json json

Config log4j2 with JSON


The log4j2 JSON (or any JSON for that matter) doesn't allow two "AppenderRef" entries to exist, so you should use a config more like the following

{ "configuration":{    "appenders": {        "RandomAccessFile": { "name": "FILE", "fileName": "app.log",            "PatternLayout": { "pattern": "%d %p %c{1.} [%t] %m%n" }        },        "Console": { "name": "STDOUT",            "PatternLayout": { "pattern": "%m%n" }        }    },    "loggers": {        "root": { "level": "trace",            "AppenderRef": [                { "ref": "STDOUT" },                { "ref": "FILE" }            ]        }    }}}

You can also use 'appender-ref' instead of AppenderRef


You may have found a bug. Could you file a Jira ticket in the log4j2 issue tracker?