You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "none (JIRA)" <ji...@apache.org> on 2017/12/13 22:13:00 UTC
[jira] [Commented] (LOG4J2-2151) Help with migrating from log4j1 to
log4j2
[ https://issues.apache.org/jira/browse/LOG4J2-2151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16290022#comment-16290022 ]
none commented on LOG4J2-2151:
------------------------------
when i do reconfigure over configurator (as i need to reset the log level back to default). i notice that it does not restart the java appenders i have.
log4j1 reset log level worked by us setting setLevel(null) but causes a null pointer in log4j2 when calling updateLogger.
> Help with migrating from log4j1 to log4j2
> -----------------------------------------
>
> Key: LOG4J2-2151
> URL: https://issues.apache.org/jira/browse/LOG4J2-2151
> Project: Log4j 2
> Issue Type: Bug
> Reporter: none
>
> Hi, im trying to migrate from log4j 1 to 2.
> Im having problems with migrating from the propertyconfigurator.
> Doing something like
> @SuppressWarnings("unchecked")
> private static void reset() throws MalformedURLException, URISyntaxException {
> LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
> Configuration config = ctx.getConfiguration();
> for (LoggerConfig loggerConfig : config.getLoggers().values()) {
> loggerConfig.setLevel(null);
> }
> Configurator.shutdown(ctx);
> String path = System.getProperty(JAVA_OPTIONS_LOG_CONFIG);
> if (Strings.isNullOrEmpty(path)) {
> ConfigurationSource source = ConfigurationSource.fromResource(LOG_CONFIGURATION, null);
> Configurator.initialize(null, source);
> } else {
> URL in = new URL(path);
> Configurator.initialize((String) null, null, in.toURI());
> }
> ctx.updateLoggers();
> }
> kinds of works but then it closes my other appenders that i started with java.
> See https://gerrit-review.googlesource.com/#/c/gerrit/+/142811/
> please could i have some help as i've spent two weeks on this and havent really moved on.
> We need to reset the loggers back to default when we do
> for example
> ssh -p 29418 admin@localhost gerrit logging set-level \
> debug com.google.
> ssh -p 29418 admin@localhost gerrit logging set-level \
> reset
> and also i found that even though i specified ConsoleAppender in log4j2.properties (resources folder in java) it dosen't seem to show any of gerrit logging when starting.
> To work around this i am adding ConsoleAppender through the ErrorLog class.
> (Sorry if this is the wrong place to ask this but i couldn't find any where else).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)