Jump to content

[1.8.9][Logger] Configuring personal logger through logging.properties


Major Squirrel

Recommended Posts

Good morning,

 

I would like to configure my own logger so that I can display some color into my console. I managed to get a Logger according to the FMLPreInitializationEvent :

 

    /**
     * Get a logger instance configured to write to the FML Log as a parent, identified by modid. Handy for mod logging!
     * Configurations can be applied through the <code>config/logging.properties</code> file, specifying logging levels
     * for your ModID. Use this!
     *
     * @return A logger
     */
    public Logger getModLog()
    {
        Logger log = LogManager.getLogger(modContainer.getModId());
        return log;
    }

 

The doc tells us to configure through a logging.properties file. However, it seems that it doesn't take the file into account. This is the logging.properties file.

 

Have you ever done this ? If yes, could you show me the way ? :)

 

EDIT : sorry, forgot to tell --> using Windows & Intellij IDEA 15.0.3. I'm aware that IDEA console is independent, which requires a lil' plugin to work with colors. I'm just trying to do this on windows console.

Squirrel ! Squirrel ! Squirrel !

Link to comment
Share on other sites

I'm pretty sure that doc comment is outdated, the method that loads logging configuration files was removed when Minecraft and Forge/FML switched to log4j from Java's Logging API.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Hello Choonster,

 

Does this mean that we can't configure our own Logger anymore?

 

I'm not an expert on log4j, but I don't think it's possible to configure an individual

Logger

. You can include a log4j config file in your mod, but this overwrites the existing configuration provided by Forge.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Hello Choonster,

 

Does this mean that we can't configure our own Logger anymore?

 

I'm not an expert on log4j, but I don't think it's possible to configure an individual

Logger

. You can include a log4j config file in your mod, but this overwrites the existing configuration provided by Forge.

 

That's right ! For about 1 hour I did some tests : if you put a config file into the classpath (ex. the resources folder), the config is loaded automatically at start.

 

Apparently, the version provided for FML is log4j 2.x which means that the config file must be called "log4j2". Sadly, I couldn't make it so that the config I provided does not overwrite Forge's config and goes on my own Logger ... (I work on console, not files)

 

If someone succeeded on this task, I would be grateful to share the answer. :)

Squirrel ! Squirrel ! Squirrel !

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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