You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "paladox (JIRA)" <ji...@apache.org> on 2017/12/14 22:15:03 UTC
[jira] [Updated] (LOG4J2-2151) Migrating from log4j1 to log4j2
[ https://issues.apache.org/jira/browse/LOG4J2-2151?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
paladox updated LOG4J2-2151:
----------------------------
Summary: Migrating from log4j1 to log4j2 (was: Help with migrating from log4j1 to log4j2)
> Migrating from log4j1 to log4j2
> -------------------------------
>
> Key: LOG4J2-2151
> URL: https://issues.apache.org/jira/browse/LOG4J2-2151
> Project: Log4j 2
> Issue Type: Bug
> Reporter: paladox
>
> 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)