Difference between revisions of "Debugging"

From wiki.vg
Jump to navigation Jump to search
(Hexadecimal)
(Include fix for https://bugs.mojang.com/browse/MC-100524 by default (especially in debug logs this is important))
Line 24: Line 24:
 
                 <OnStartupTriggeringPolicy />
 
                 <OnStartupTriggeringPolicy />
 
             </Policies>
 
             </Policies>
 +
            <DefaultRolloverStrategy max="999999"/>
 
         </RollingRandomAccessFile>
 
         </RollingRandomAccessFile>
 
     </Appenders>
 
     </Appenders>
Line 72: Line 73:
 
                 <OnStartupTriggeringPolicy />
 
                 <OnStartupTriggeringPolicy />
 
             </Policies>
 
             </Policies>
 +
            <DefaultRolloverStrategy max="999999"/>
 
         </RollingRandomAccessFile>
 
         </RollingRandomAccessFile>
 
     </Appenders>
 
     </Appenders>

Revision as of 23:32, 7 June 2016

Minecraft's client and server can log every packet which can be helpful for debugging. It can also log a large amount of other information should it be necessary, beyond what is normally found in the logs.

   -Dlog4j.configurationFile=fullpathtoconfigfile.xml

The -Dlog4j.configurationFile=fullpathtoconfigfile.xml should be placed:

where the config file should contain

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.minecraft,com.mojang">
    <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="999999"/>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <filters>
                <MarkerFilter marker="NETWORK_PACKETS" onMatch="ACCEPT" onMismatch="NEUTRAL" />
            </filters>
            <AppenderRef ref="SysOut"/>
            <AppenderRef ref="File"/>
            <AppenderRef ref="ServerGuiConsole"/>
        </Root>
    </Loggers> 
</Configuration>

Doing this will display some packet information in the console. Unfortunately after the netty rewrite (1.7), only packet names and IDs are shown; packet content is no longer given. Nevertheless, this information still can be useful.

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

[08:21:44] [Netty Client IO #0/DEBUG]: OUT: [HANDSHAKING:0] jd
[08:21:44] [Netty Client IO #0/DEBUG]: OUT: [STATUS:0] jw
[08:21:44] [Netty Client IO #0/DEBUG]:  IN: [STATUS:0] js
[08:21:44] [Netty Client IO #0/DEBUG]: OUT: [STATUS:1] jv
[08:21:44] [Netty Client IO #0/DEBUG]:  IN: [STATUS:1] jr
[08:21:52] [Netty Client IO #1/DEBUG]: OUT: [HANDSHAKING:0] jd
[08:21:52] [Netty Client IO #1/DEBUG]: OUT: [LOGIN:0] jm
[08:21:52] [Netty Client IO #1/DEBUG]:  IN: [LOGIN:1] ji

Minecraft can do even more logging should you need it, if you allow it to log all sections.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="net.minecraft,com.mojang">
    <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="999999"/>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="SysOut"/>
            <AppenderRef ref="File"/>
            <AppenderRef ref="ServerGuiConsole"/>
        </Root>
    </Loggers> 
</Configuration>

This will give you information about networking, sounds, authentication, and several other categories.