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.
Fabrified NeoForge Log4J Config
<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment