Change how logging works to make configuration easier #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a short discussion in the NeoForged discord about ways that configuring logging could be made easier for mod developers and users, and this is roughly what came from that discussion.
It's not the cleanest code, but the main goal is to get feedback on the basic idea of configuring logging in this way.
For modders and users, general logging configuration should be done by the system properties under
logging.*
:logging.loglevel.*
configures the log levels for the logger with the given name.logging.loglevel.default
configures the root logger level. Loggers will default to this level unless otherwise specified.logging.loglevel.mypackage
configures all loggers in themypackage
package.logging.loglevel.mypackage.mysubpackage
.logging.loglevel.mypackage.mysubpackage.MyLoggedClass
.logging.marker.*
configures the minimum log level for a given marker. For example, if you wanted to turn on trace logging for launch plugins, you could specifylogging.marker.LAUNCHPLUGIN=TRACE
.logging.loglevel.*
, so you can specifylogging.loglevel.default=WARN
andlogging.marker.COOLMARKER=TRACE
to turn on trace logging for any log message using theCOOLMARKER
marker.Configuring the nitty-gritty of logging consists of specifying one or more
--loggingConfig
parameters, which is a URI to a valid log4j configuration file. These are aggregated by ModLauncher and used to populate the logging configuration fairly early on in the startup path. I imagine NeoForge/FancyModLoader would want to specify a--loggingConfig
parameter to configure their marker filter defaults, or to add their custom log appenders for the server console.As for why I decided to put these changes into ModLauncher, I felt that centralising all configuration in a single place would be ideal, and doing it early on in the startup process means that we can ensure a reliable foundation for the entire lifecycle of a launched game.