Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISIS-1979: Refactor logging in headless runtime and prevent configuri… #122

Merged
merged 1 commit into from
Sep 8, 2018
Merged

Conversation

blaugold
Copy link
Contributor

@blaugold blaugold commented Sep 8, 2018

…g log4j twice

Without these changes, IsisSystem is setting up log4j which is too late since other classes which
bootstrap Isis require logging to work. Currently, HeadlessWithBootstrappingAbstract configures log4j in
addition to IsisSystem. IsisSystem sets up logging either through logging.properties or a fallback. But
logging.properties does not always exist (integration tests). Without logging.properties the fallback
adds a console appender to the root logger in addition to any configuration in logging-integtest.properties,
resulting in duplicated logs in integration tests.

This commit removes any logging setup from IsisSystem. HeadlessWithBootstrappingAbstract now uses the
IsisLoggingConfigurer which is normally used to set up logging. This requires IsisLoggingConfigurer to
be flexible as to the basename of the configuration file.

Also, some code duplication is refactored into LeveledLogger.

…ng log4j twice

thout these changes, IsisSystem is setting up log4j which is too late since other classes which
bootstrap Isis require logging to work. Currently, HeadlessWithBootstrappingAbstract configures log4j in
addition to IsisSystem. IsisSystem sets up logging either through logging.properties or a fallback. But
logging.properties does not always exist (integration tests). Without logging.properties the fallback
adds a console appender to the root logger in addition to any configuration in logging-integtest.properties,
resulting in duplicated logs in integration tests.

This commit removes any logging setup from IsisSystem. HeadlessWithBootstrappingAbstract now uses the
IsisLoggingConfigurer which is normally used to set up logging. This requires IsisLoggingConfigurer to
be flexible as to the basename of the configuration file.

Also, some code duplication is refactored into LeveledLogger.
@@ -0,0 +1,36 @@
package org.apache.isis.core.runtime.headless.logging;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to let you know: files do need a license header; but I can fix that after merge

configureLoggingWithFile(configDirectory + "/" + LoggingConstants.LOGGING_CONFIG_FILE, args);
}

public void configureLoggingWithFile(final String configFile, final String[] args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@andi-huber andi-huber merged commit 7baf89b into apache:master Sep 8, 2018
@andi-huber
Copy link
Contributor

You know, contributions, that reduce lines of code, are the best.
Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants