Difference between revisions of "Debugging"

From wiki.vg
Jump to navigation Jump to search
(More info, more categories.)
(Hexadecimal)
Line 40: Line 40:
  
 
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.
 
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|Packet IDs are shown in decimal in logs; they are not in hexadecimal.}}
  
 
<pre>
 
<pre>

Revision as of 15:36, 2 April 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>
        </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>
        </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.