Debugging

From wiki.vg
Revision as of 21:00, 1 November 2016 by Pokechu22 (talk | contribs) (Partial rewrite (will expand later))
Jump to navigation Jump to search

The Notchian client and server (and additionally the launcher) can generate additional log information that what is normally displayed, some of which is extremely helpful for debugging. This can be done by specifying a custom Log4j configuration by supplying a -Dlog4j.configurationFile=fullpathtoconfigfile.xml argument to the game:

Warning.png If the configuration specified with -Dlog4j.configurationFile cannot be found, the default one will silently be used instead.

You can get the default configuration for the game by extracting log4j2.xml from the jar you wish to work with.

Options

The main settings that are worth modifying is the value of level in Root, and the list of filters. (SOUNDS, NETWORK, NETWORK_PACKETS, PACKET_SENT, PACKET_RECEIVED)

Sample configs

Network packets only

Applies to: vanilla client and server

Produces logs of all packets sent to and from the server/client, and nothing else (this also disables logging of normal content, including chat). Unfortunately, since the Netty rewrite (Minecraft 1.7) only packet IDs and classes are logged, and not their contents; however, this information may still be helpful.

Warning.png Packet IDs are shown in decimal in logs; they are not in hexadecimal.

Config:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
    <Appenders>
        <Console name="SysOut" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
        </Console>
        <Queue name="ServerGuiConsole">
            <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
        </Queue>
        <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
            <Policies>
                <TimeBasedTriggeringPolicy />
                <OnStartupTriggeringPolicy />
            </Policies>
            <DefaultRolloverStrategy max="1000"/>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <filters>
                <MarkerFilter marker="NETWORK_PACKETS" onMatch="ACCEPT" onMismatch="DENY" />
            </filters>
            <AppenderRef ref="SysOut"/>
            <AppenderRef ref="File"/>
            <AppenderRef ref="ServerGuiConsole"/>
        </Root>
    </Loggers> 
</Configuration>

All debug information

Applies to: vanilla client and server

You can log even more information if you want. This will print normal log messages (such as chat), but also network packets, sounds starting/stopping playing (client only), some authentication requests, and other miscellaneous information.

Config:

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
    <Appenders>
        <Console name="SysOut" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
        </Console>
        <Queue name="ServerGuiConsole">
            <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
        </Queue>
        <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
            <Policies>
                <TimeBasedTriggeringPolicy />
                <OnStartupTriggeringPolicy />
            </Policies>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="SysOut"/>
            <AppenderRef ref="File"/>
            <AppenderRef ref="ServerGuiConsole"/>
        </Root>
    </Loggers>
</Configuration>

All debug information on CraftBukkit/Spigot

Applies to: CraftBukkit servers and servers that derive from CraftBukkit

Because CraftBukkit uses slightly different console output (and has no server GUI), the configuration needs to be slightly tweaked to display correctly. However, doing this will also display the remapped packet class names.

Config:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.minecraft,com.mojang">
    <Appenders>
        <Console name="WINDOWS_COMPAT" target="SYSTEM_OUT"></Console>
        <Queue name="TerminalConsole">
            <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
        </Queue>
        <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
            <Policies>
                <TimeBasedTriggeringPolicy />
                <OnStartupTriggeringPolicy />
            </Policies>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="WINDOWS_COMPAT"/>
            <AppenderRef ref="File"/>
            <AppenderRef ref="TerminalConsole"/>
        </Root>
    </Loggers>
</Configuration>