How to log information in Forge?
Asked Answered
O

3

8

I'm trying to log into using MinecraftServer.logInfo(), but I get a nosuchmethod exception.

    server.logInfo("Example message");

I'm getting the instance of MinecraftServer in the server starting event.

    MinecraftServer server = event.getServer();
Osbourn answered 22/9, 2017 at 15:47 Comment(0)
E
8

I'm pretty sure a simple

System.out.println("Information!");

Should do in forge.

Equiponderate answered 22/9, 2017 at 16:40 Comment(0)
P
11

An option for a fully fledged logger is

Logger logger = LogManager.getLogger(YourMod.MODID);
Parlor answered 16/10, 2017 at 22:28 Comment(1)
This is a better alternative to the suggested preInit code event.getModLog(), as some things apparently run before preInit and still need to be logged. This can be set right where it's declared as public static final Logger in the main class and it's wonderful, works like a charm. You just have to remember to import org.apache.logging.log4j.Logger; and import org.apache.logging.log4j.LogManager;Tulatulip
E
8

I'm pretty sure a simple

System.out.println("Information!");

Should do in forge.

Equiponderate answered 22/9, 2017 at 16:40 Comment(0)
B
0

You also can use FMLLog for this:

FMLLog.info();
FMLLog.warning();
FMLLog.log();
[...]
Bunkmate answered 30/7, 2024 at 8:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Guglielmo

© 2022 - 2025 — McMap. All rights reserved.