Jump to content

[1.7.10][Style] Usage of logger


Recommended Posts

The question seems simple: When and how should I use the different levels of the logger?


I have two stages of developement: dev and release. Now I figured out that I should avoid having to call log with Level.DEBUG in the release but what about the other levels? Where is the difference between trace and info for example?


We have the following levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE.


OFF: should not be used at all?

FATAL: is it good style to log in case something went wrong and NOT throw an exception (do both?)

ERROR: I don't understand this Level, maybe when loading something not completly necessary, like a missing file?

WARN: okay, this is pretty clear, we do this if some (API-)user gave us wrongly formatted input but we can recover.

INFO: is this meant to info the final user? If so, how deep of an understanding should I assume?

DEBUG: should I include this in the final product, after all?

TRACE: how often should I use this feature? excessively?

Link to comment
Share on other sites

It strongly depends on your own opinion. There are as far as I know no global standards on how to log especially not in Minecraft because nobody really cares about it.

But it is good to give it some structure. I wouldn't log an Error as an INFO because it is much easier to read for the user / programmer in case something went wrong. Most of the time you wont need to log something anyways because logs (especially Debugging messages) just spam the console. For instance a TileEntity logging its position. When an Error occurs you should log it as an Error as long as it doesn't crash the game or creates world damage (that would probably be a "Fatal") and log the Stacktrace with it so the user / programmer can see where the problem is and avoid / debug it. A common usage for the ERROR level is in try-catch blocks where an Error wont crash the game but still would create some trouble.

I commonly use these LEVELS...

  • FATAL: Errors that will crash the game.
  • ERROR: Errors that have to be debugged or occur randomly in try-catch blocks.
  • WARN: Things that are not really normal but wont throw an exception.
  • INFO: Information for the end User, for instance printing the mod version.
  • DEBUG: Messages from debugging... (I have a config Flag for a debug mode)


As I said it strongly depends on your opinion and can vary.


- Busti

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.