Change how logging works to make configuration easier#119
Draft
FiniteReality wants to merge 2 commits intoMcModLauncher:mainfrom
Draft
Change how logging works to make configuration easier#119FiniteReality wants to merge 2 commits intoMcModLauncher:mainfrom
FiniteReality wants to merge 2 commits intoMcModLauncher:mainfrom
Conversation
Minecraftschurli
approved these changes
Oct 17, 2023
Minecraftschurli
left a comment
There was a problem hiding this comment.
Looks good, the logging.loglevel prefix looks a bit clunky to me because it contains log twice but it's fine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.defaultconfigures the root logger level. Loggers will default to this level unless otherwise specified.logging.loglevel.mypackageconfigures all loggers in themypackagepackage.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=WARNandlogging.marker.COOLMARKER=TRACEto turn on trace logging for any log message using theCOOLMARKERmarker.Configuring the nitty-gritty of logging consists of specifying one or more
--loggingConfigparameters, 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--loggingConfigparameter 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.