Skip to content

Instantly share code, notes, and snippets.

@sylv256
Forked from FiniteReality/log4j2.xml
Last active October 12, 2024 03:30
Show Gist options
  • Select an option

  • Save sylv256/2b9c6734b56cadee8b669ad18006935d to your computer and use it in GitHub Desktop.

Select an option

Save sylv256/2b9c6734b56cadee8b669ad18006935d to your computer and use it in GitHub Desktop.

Revisions

  1. sylv256 revised this gist Oct 12, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    <Configuration status="WARN">
    <Appenders>
    <!-- Standard output -->
    <TerminalConsole name="SysOut" target="SYSTEM_OUT">
    <TerminalConsole name="SysOut">
    <Select>
    <!-- If we're running through the launcher, format messages using XML -->
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
  2. sylv256 revised this gist Oct 12, 2024. 1 changed file with 80 additions and 78 deletions.
    158 changes: 80 additions & 78 deletions log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -1,85 +1,87 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="WARN">
    <Appenders>
    <!-- Standard output -->
    <TerminalConsole name="SysOut" target="SYSTEM_OUT">
    <Select>
    <!-- If we're running through the launcher, format messages using XML -->
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
    <LegacyXMLLayout/>
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console -->
    <DefaultArbiter>
    <!-- Support ANSI escape sequences if we're running interactively -->
    <PatternLayout disableAnsi="false" noConsoleNoAnsi="true" pattern="%highlight{[%d{HH:mm:ss}] [%t/%level] [%c]: %msg{nolookups}%n}"/>
    </DefaultArbiter>
    </Select>
    </TerminalConsole>
    <!-- Interactive server console -->
    <Queue name="ServerGuiConsole">
    <!-- This is the same format used by the standard vanilla console -->
    <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n"/>
    </Queue>
    <!-- File logging -->
    <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
    <!-- Strip any ANSI escape sequences if possible, and use a derivative of the vanilla format which includes the logger name -->
    <!-- TODO: it would be nice to include the mod id here too; this would likely need a custom context lookup though and may not work -->
    <PatternLayout disableAnsi="true" pattern="[%d{HH:mm:ss}] [%t/%level] [%c]: %msg{nolookups}%n">
    <Policies>
    <!-- Only roll over per launch of the game/server -->
    <!-- This is for ease of bug reports: users only have to upload logs/latest.log -->
    <OnStartupTriggeringPolicy/>
    </Policies>
    <!-- Only keep the past 10 logfiles to prevent logfile spam -->
    <DefaultRolloverStrategy max="10" fileIndex="min"/>
    </RollingRandomAccessFile>
    </Appenders>
    <Appenders>
    <!-- Standard output -->
    <TerminalConsole name="SysOut" target="SYSTEM_OUT">
    <Select>
    <!-- If we're running through the launcher, format messages using XML -->
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
    <LegacyXMLLayout/>
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console -->
    <DefaultArbiter>
    <!-- Support ANSI escape sequences if we're running interactively -->
    <PatternLayout pattern="%style{[%d{HH:mm:ss}]}{blue} %highlight{[%t/%level]}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=green, TRACE=blue} %style{(%logger{1})}{cyan} %highlight{%msg%n}{FATAL=red, ERROR=red, WARN=normal, INFO=normal, DEBUG=normal, TRACE=normal}">
    <Replace regex="\r?\n(?!\Z)" replacement="${sys:line.separator}" />
    </PatternLayout>
    </DefaultArbiter>
    </Select>
    </TerminalConsole>
    <!-- Interactive server console -->
    <Queue name="ServerGuiConsole">
    <!-- This is the same format used by the standard vanilla console -->
    <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n"/>
    </Queue>
    <!-- File logging -->
    <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
    <!-- Strip any ANSI escape sequences if possible, and use a derivative of the vanilla format which includes the logger name -->
    <!-- TODO: it would be nice to include the mod id here too; this would likely need a custom context lookup though and may not work -->
    <PatternLayout disableAnsi="true" pattern="[%d{HH:mm:ss}] [%t/%level] [%c]: %msg{nolookups}%n"/>
    <Policies>
    <!-- Only roll over per launch of the game/server -->
    <!-- This is for ease of bug reports: users only have to upload logs/latest.log -->
    <OnStartupTriggeringPolicy/>
    </Policies>
    <!-- Only keep the past 10 logfiles to prevent logfile spam -->
    <DefaultRolloverStrategy max="10" fileIndex="min"/>
    </RollingRandomAccessFile>
    </Appenders>

    <Loggers>
    <!-- Minecraft uses isDebugEnabled() in some places to add additional debug logic, which we typically don't want enabled. -->
    <Logger name="com.mojang" level="INFO"/>
    <Logger name="net.minecraft" level="INFO"/>
    <Loggers>
    <!-- Minecraft uses isDebugEnabled() in some places to add additional debug logic, which we typically don't want enabled. -->
    <Logger name="com.mojang" level="INFO"/>
    <Logger name="net.minecraft" level="INFO"/>

    <!-- Hide class transform logging -->
    <Logger name="cpw.mods.modlauncher.ClassTransformer" level="INFO"/>
    <!-- Hide class transform logging -->
    <Logger name="cpw.mods.modlauncher.ClassTransformer" level="INFO"/>

    <!-- Netty has extra requirements for modular environments which we can't yet satisfy: https://github.com/netty/netty/issues/7838 -->
    <!-- This causes errors we can't hide, as netty is not on the module boot path: https://github.com/neoforged/FancyModLoader/pull/61 -->
    <Logger name="io.netty.util.internal.PlatformDependent0">
    <Filters>
    <RegexFilter regex="^direct buffer constructor: unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    <RegexFilter regex="^jdk\.internal\.misc\.Unsafe\.allocateUninitializedArray\(int\): unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    </Filters>
    </Logger>
    <!-- Netty has extra requirements for modular environments which we can't yet satisfy: https://github.com/netty/netty/issues/7838 -->
    <!-- This causes errors we can't hide, as netty is not on the module boot path: https://github.com/neoforged/FancyModLoader/pull/61 -->
    <Logger name="io.netty.util.internal.PlatformDependent0">
    <Filters>
    <RegexFilter regex="^direct buffer constructor: unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    <RegexFilter regex="^jdk\.internal\.misc\.Unsafe\.allocateUninitializedArray\(int\): unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    </Filters>
    </Logger>

    <!-- Default logging inherited by all loggers. Users can specify loglevels for specific loggers in a composite configuration. -->
    <Root level="INFO">
    <Filters>
    <!-- Hide network packet logging a la vanilla -->
    <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <!-- Also hide our more advanced logging -->
    <MarkerFilter marker="CLASSLOADING" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="LAUNCHPLUGIN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="CLASSDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="AXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="EVENTBUS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="DISTXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SCAN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRIES" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRYDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SPLASH" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="RESOURCE-CACHE" onMatch="DENY" onMismatch="NEUTRAL"/>
    </Filters>
    <AppenderRef ref="SysOut">
    <!-- Only send info and above to stdout -->
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    <!-- File logging can get everything, including debug messages, to make uploading logs easier. -->
    <AppenderRef ref="File"/>
    <!-- The server GUI console is meant to mirror stdout -->
    <AppenderRef ref="ServerGuiConsole">
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    </Root>
    </Loggers>
    <!-- Default logging inherited by all loggers. Users can specify loglevels for specific loggers in a composite configuration. -->
    <Root level="INFO">
    <Filters>
    <!-- Hide network packet logging a la vanilla -->
    <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <!-- Also hide our more advanced logging -->
    <MarkerFilter marker="CLASSLOADING" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="LAUNCHPLUGIN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="CLASSDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="AXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="EVENTBUS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="DISTXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SCAN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRIES" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRYDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SPLASH" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="RESOURCE-CACHE" onMatch="DENY" onMismatch="NEUTRAL"/>
    </Filters>
    <AppenderRef ref="SysOut">
    <!-- Only send info and above to stdout -->
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    <!-- File logging can get everything, including debug messages, to make uploading logs easier. -->
    <AppenderRef ref="File"/>
    <!-- The server GUI console is meant to mirror stdout -->
    <AppenderRef ref="ServerGuiConsole">
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    </Root>
    </Loggers>
    </Configuration>
  3. @FiniteReality FiniteReality revised this gist Apr 13, 2024. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -36,14 +36,15 @@
    </Appenders>

    <Loggers>
    <!-- Hide Mojang's debug logging -->
    <!-- Minecraft uses isDebugEnabled() in some places to add additional debug logic, which we typically don't want enabled. -->
    <Logger name="com.mojang" level="INFO"/>
    <Logger name="net.minecraft" level="INFO"/>

    <!-- Hide class transform logging -->
    <Logger name="cpw.mods.modlauncher.ClassTransformer" level="INFO"/>

    <!-- Netty reflects into JDK internals, and it's causing useless DEBUG-level error stacktraces. We just ignore them -->
    <!-- Netty has extra requirements for modular environments which we can't yet satisfy: https://github.com/netty/netty/issues/7838 -->
    <!-- This causes errors we can't hide, as netty is not on the module boot path: https://github.com/neoforged/FancyModLoader/pull/61 -->
    <Logger name="io.netty.util.internal.PlatformDependent0">
    <Filters>
    <RegexFilter regex="^direct buffer constructor: unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
  4. @FiniteReality FiniteReality revised this gist Mar 17, 2024. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,8 @@
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console -->
    <DefaultArbiter>
    <PatternLayout pattern="%highlight{[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n}"/>
    <!-- Support ANSI escape sequences if we're running interactively -->
    <PatternLayout disableAnsi="false" noConsoleNoAnsi="true" pattern="%highlight{[%d{HH:mm:ss}] [%t/%level] [%c]: %msg{nolookups}%n}"/>
    </DefaultArbiter>
    </Select>
    </TerminalConsole>
    @@ -21,8 +22,9 @@
    </Queue>
    <!-- File logging -->
    <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
    <!-- This is the same format used by the vanilla file logger -->
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    <!-- Strip any ANSI escape sequences if possible, and use a derivative of the vanilla format which includes the logger name -->
    <!-- TODO: it would be nice to include the mod id here too; this would likely need a custom context lookup though and may not work -->
    <PatternLayout disableAnsi="true" pattern="[%d{HH:mm:ss}] [%t/%level] [%c]: %msg{nolookups}%n">
    <Policies>
    <!-- Only roll over per launch of the game/server -->
    <!-- This is for ease of bug reports: users only have to upload logs/latest.log -->
    @@ -49,8 +51,8 @@
    </Filters>
    </Logger>

    <!-- Default logging inherited by all loggers -->
    <Root level="all">
    <!-- Default logging inherited by all loggers. Users can specify loglevels for specific loggers in a composite configuration. -->
    <Root level="INFO">
    <Filters>
    <!-- Hide network packet logging a la vanilla -->
    <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
  5. @FiniteReality FiniteReality revised this gist Feb 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console -->
    <DefaultArbiter>
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    <PatternLayout pattern="%highlight{[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n}"/>
    </DefaultArbiter>
    </Select>
    </TerminalConsole>
  6. @FiniteReality FiniteReality revised this gist Feb 29, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    <Configuration status="WARN">
    <Appenders>
    <!-- Standard output -->
    <Console name="SysOut" target="SYSTEM_OUT">
    <TerminalConsole name="SysOut" target="SYSTEM_OUT">
    <Select>
    <!-- If we're running through the launcher, format messages using XML -->
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
    @@ -13,7 +13,7 @@
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    </DefaultArbiter>
    </Select>
    </Console>
    </TerminalConsole>
    <!-- Interactive server console -->
    <Queue name="ServerGuiConsole">
    <!-- This is the same format used by the standard vanilla console -->
  7. @FiniteReality FiniteReality revised this gist Feb 29, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
    <LegacyXMLLayout/>
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console-->
    <!-- Otherwise, use the vanilla format assuming it's a console -->
    <DefaultArbiter>
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    </DefaultArbiter>
  8. @FiniteReality FiniteReality created this gist Feb 29, 2024.
    82 changes: 82 additions & 0 deletions log4j2.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,82 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="WARN">
    <Appenders>
    <!-- Standard output -->
    <Console name="SysOut" target="SYSTEM_OUT">
    <Select>
    <!-- If we're running through the launcher, format messages using XML -->
    <SystemPropertyArbiter propertyName="minecraft.launcher.brand" propertyValue="minecraft-launcher">
    <LegacyXMLLayout/>
    </SystemPropertyArbiter>
    <!-- Otherwise, use the vanilla format assuming it's a console-->
    <DefaultArbiter>
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    </DefaultArbiter>
    </Select>
    </Console>
    <!-- Interactive server console -->
    <Queue name="ServerGuiConsole">
    <!-- This is the same format used by the standard vanilla console -->
    <PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg{nolookups}%n"/>
    </Queue>
    <!-- File logging -->
    <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
    <!-- This is the same format used by the vanilla file logger -->
    <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
    <Policies>
    <!-- Only roll over per launch of the game/server -->
    <!-- This is for ease of bug reports: users only have to upload logs/latest.log -->
    <OnStartupTriggeringPolicy/>
    </Policies>
    <!-- Only keep the past 10 logfiles to prevent logfile spam -->
    <DefaultRolloverStrategy max="10" fileIndex="min"/>
    </RollingRandomAccessFile>
    </Appenders>

    <Loggers>
    <!-- Hide Mojang's debug logging -->
    <Logger name="com.mojang" level="INFO"/>
    <Logger name="net.minecraft" level="INFO"/>

    <!-- Hide class transform logging -->
    <Logger name="cpw.mods.modlauncher.ClassTransformer" level="INFO"/>

    <!-- Netty reflects into JDK internals, and it's causing useless DEBUG-level error stacktraces. We just ignore them -->
    <Logger name="io.netty.util.internal.PlatformDependent0">
    <Filters>
    <RegexFilter regex="^direct buffer constructor: unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    <RegexFilter regex="^jdk\.internal\.misc\.Unsafe\.allocateUninitializedArray\(int\): unavailable$" onMatch="DENY" onMismatch="NEUTRAL" />
    </Filters>
    </Logger>

    <!-- Default logging inherited by all loggers -->
    <Root level="all">
    <Filters>
    <!-- Hide network packet logging a la vanilla -->
    <MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <!-- Also hide our more advanced logging -->
    <MarkerFilter marker="CLASSLOADING" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="LAUNCHPLUGIN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="CLASSDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="AXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="EVENTBUS" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="DISTXFORM" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SCAN" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRIES" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="REGISTRYDUMP" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="SPLASH" onMatch="DENY" onMismatch="NEUTRAL"/>
    <MarkerFilter marker="RESOURCE-CACHE" onMatch="DENY" onMismatch="NEUTRAL"/>
    </Filters>
    <AppenderRef ref="SysOut">
    <!-- Only send info and above to stdout -->
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    <!-- File logging can get everything, including debug messages, to make uploading logs easier. -->
    <AppenderRef ref="File"/>
    <!-- The server GUI console is meant to mirror stdout -->
    <AppenderRef ref="ServerGuiConsole">
    <ThresholdFilter level="INFO"/>
    </AppenderRef>
    </Root>
    </Loggers>
    </Configuration>