Skip to content

Instantly share code, notes, and snippets.

@maruohon
Last active September 17, 2021 10:08
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maruohon/7290185 to your computer and use it in GitHub Desktop.
Save maruohon/7290185 to your computer and use it in GitHub Desktop.
Minecraft server logging configuration file for Minecraft 1.7.2+
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="legacy_server_log" fileName="server.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%level] %msg%n" />
</File>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%level] %msg%n" />
</Console>
<RollingFile name="rolling_server_log" fileName="logs/server.log"
filePattern="logs/server_%d{yyyy-MM-dd}.log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%level] %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<!-- <AppenderRef ref="rolling_server_log" /> -->
<AppenderRef ref="legacy_server_log" />
<AppenderRef ref="console" />
</Root>
</Loggers>
</Configuration>
@maruohon
Copy link
Author

maruohon commented Nov 3, 2013

Place the file to the same directory as your minecraft_server.jar, and add -Dlog4j.configurationFile=log4j2.xml to your server startup arguments.

The given configuration mimics the old logging behaviour.

If you want daily rolled logs, uncomment the <AppenderRef ref="rolling_server_log" /> line (and probably comment out the the legacy_server_log since you don't then want that?). For compressed rolled logs, add .gz to the end of the filePattern's filename pattern (logs/server_%d{yyyy-MM-dd}.log.gz).

@ttran17
Copy link

ttran17 commented Nov 4, 2013

Thanks! Saved me the time and hassle of doing this myself.

@Hawkers
Copy link

Hawkers commented Feb 4, 2014

This is great, but it breaks the console output. I'm trying to figure out a solution.

@maruohon
Copy link
Author

How does it break it? It was supposed to work/output exactly the way it worked before 1.7, and afaik it does that on all of my servers.

@minetonight
Copy link

I love my logs to be at one place, but it turns out, adding that option "-Dlog4j.configurationFile=log4j2.xml" makes my server eat 100%+ CPU time on empty and idle server. Do you have any idea why?
Its on Linux laptop 3.12.2-1-ARCH x86_64 GNU/Linux
and also on
Linux Ubuntu 2.6.35-22-server x86_64 x86_64 x86_64 GNU/Linux

Best regards

EDIT:
Well, https://gist.github.com/EvilSeph/7909975 works fine for me. Maybe I edited badly your xml, maybe not.

@cloakable
Copy link

Thank you for this! I've been looking for a way to control Forge logging for some time.

@RainbowStickDude
Copy link

sooo confused xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment