7

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();
Alsan Ali
  • 187
  • 2
  • 10

2 Answers2

10

An option for a fully fledged logger is

Logger logger = LogManager.getLogger(YourMod.MODID);
phlaxyr
  • 923
  • 1
  • 8
  • 22
  • 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;` – RoboticRenaissance Oct 07 '18 at 15:02
6

I'm pretty sure a simple

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

Should do in forge.

086
  • 197
  • 13