Mojira Archive
MC-38972

Log4j2 doesnt escape " when using JSONLayout

Log4j2 doesnt escape " when using JSONLayout.

What I expected to happen was...:
Log4j2 should output this when using JSONLayout:

{ "logger": "lj", "timestamp": "1383520323312", "level": "INFO", "thread": "Server thread", "message": "Preparing level \"flatty\"" }

What actually happened was...:
Log4j2 actually outputs this:

{ "logger": "lj", "timestamp": "1383520323312", "level": "INFO", "thread": "Server thread", "message": "Preparing level "flatty"" }
  • It does not escape double quotes within message.

Steps to Reproduce:
1. Download server.jar
2. Make the following log4j2.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.minecraft,com.mojang">
    <Appenders>
        <File name="jsonwrite" fileName="ex.json">
            <JSONLayout/>
        </File>
    </Appenders>
    <Loggers>
        <Root level="info">
            <filters>
                <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
            </filters>
            <AppenderRef ref="jsonwrite"/>
        </Root>
    </Loggers>
</Configuration>

3. Start server with following command: java -Dlog4j.configurationFile=log4j2.xml -jar minecraft_server.jar nogui
4. Stop server
5. ex.json is not escaped correctly.

Invalid

Jacob Honore

[Mojang] Nathan Adams

2013-11-04, 12:17 PM

2015-09-07, 04:10 AM

2014-01-17, 01:38 PM

0

2

Unconfirmed

server

Minecraft 1.7.2, Minecraft 14w03b

-