Page tree
Skip to end of metadata
Go to start of metadata


Continue Log4j2 Upgrade, provide more detail information on how to achieve this.

Updated Information


  • Latest version: 2.8.2
  • We went for a bigger migration and eradicated Log4j 1.2.x API from our product modules, bundles, and tests.
  • We will document the upgrade, including possibility for projects to use the bridge library org.apache.logging.log4j:log4j-1.2-api:2.8.2 for backward compatibility
    • see  DOCU-1164 - Getting issue details... STATUS

Implementation


After upgrade:

with Log Tools app 1.1, adapted to log4j 2.

libs and dependencies status: ui-tree.txtmain-tree.txtdev-web-app-tree.txtdev-web-app-lib.txt

Suggest for fix issues mentioned in previous investigation


New package

DOM and Property Configurator was removed

  • Need to update implementation:

Log4J2 over the old fashioned properties file is not supported so far

  • Support for old log configuration file is still not available yet. Suggest to:
    • Provide default log4j2.xml file
    • A fallback mechanism to use default log4j2.xml in case cannot parse configured file.

API for setLevel / getEffectiveLevel

Custom Level

  • Sample deprecated declaration:
Deprecated declaration
public class LoggingLevel extends Level {
 
    public static final LoggingLevel AUDIT_TRAIL = new LoggingLevel(99, "AUDIT_TRAIL", 0);
 
    protected LoggingLevel(int level, String levelStr, int syslogEquivalent) {
        super(level, levelStr, syslogEquivalent);
    }
 
    public static Level toLevel(String sArg) {
        return AUDIT_TRAIL;
    }
 
    public static Level toLevel(int val) {
        return AUDIT_TRAIL;
    }
 
}
  • Deprecate preference (info.magnolia.audit.AuditLoggingManager)
Deprecated preference
org.apache.log4j.Logger.getLogger(trail.getLogName()).log(LoggingLevel.AUDIT_TRAIL, message.toString());
  • Update to:
Updated
public class CustomLogLevel {
    public static final org.apache.logging.log4j.Level AUDIT_TRAIL = org.apache.logging.log4j.Level.forName("AUDIT_TRAIL", 99);
}
Updated
org.apache.logging.log4j.LogManager.getLogger(trail.getName()).log(LoggingLevel.AUDIT_TRAIL, message.toString();

Unit-testing

Many tests are reconfiguring loggers for getting/verifying log content. Using old APIs, those tests are either failed to compile or error.

  • Add Appender
Deprecated
Writer loggerOut = new StringWriter();
final Layout layout = new EnhancedPatternLayout(EnhancedPatternLayout.TTCC_CONVERSION_PATTERN);
Logger.getRootLogger().setLevel(Level.INFO); // Other tests might have set this to silent
Logger.getRootLogger().addAppender(new WriterAppender(layout, loggerOut));
Updated
StringWriter stringWriter = new StringWriter();
StringLayout layout = PatternLayout.createDefaultLayout();
Appender appender = WriterAppender.newBuilder().setName("name").setLayout(layout).setTarget(stringWriter).build();
org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) org.apache.logging.log4j.LogManager.getRootLogger();
coreLogger.setLevel(org.apache.logging.log4j.Level.WARNING);


  • Custom Appender
Deprecated
public static class TestAppender extends AppenderSkeleton {
    public List<LoggingEvent> events = new ArrayList<>();
 
    @Override
    public void close() {
    }
 
    @Override
    public boolean requiresLayout() {
        return false;
    }
 
    @Override
    protected void append(LoggingEvent event) {
        events.add(event);
    }
}
Updated
public class Log4j2TestAppender extends AbstractAppender {
	
	//for verifying.
    List<LogEvent> events = new ArrayList();

    public Log4j2TestAppender(String name, Filter filter, Layout<? extends Serializable> layout) {
        super(name, filter, layout);
    }

    @Override
    public void append(LogEvent event) {
        events.add(event);
    }

    public List<LogEvent> getEvents() {
        return events;
    }
}


Log Tools can not start due to it relies on Log4j

Fixed by Upgrade to log4j2

Affected product modules


ModuleAffected FilesRemoveNote
(tick)

ENTERPRISE/repos/advanced-cache - MGNLADVCACHE-95

magnolia-advanced-cache/src/test/java/info/magnolia/module/advancedcache/EagerRecacheFlushPolicyTest.java


org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

org.apache.log4j.Level

compile error / test failed
magnolia-advanced-cache/src/test/java/info/magnolia/module/advancedcache/NotifyFlushListeningPolicyRepositoryTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

compile error / test failed
(tick)ENTERPRISE/repos/content-translation-supportinfo/magnolia/module/contenttranslationsupport/reimport/TranslationBundleUpdater.javaorg.apache.log4j.Loggercompile error

ENTERPRISE/repos/ldap - MGNLLDAP-114

(info) PR ready - ldap is not bundled, hence not blocking

magnolia-ldap/src/test/java/info/magnolia/jaas/sp/ldap/TesterTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

compile error / test failed


ENTERPRISE/repos/personalization - MGNLPN-401

(info) can wait, no log4j dependency at runtime, version is still 5.5-based

magnolia-personalization-preview-app/src/test/java/info/magnolia/personalization/preview/ui/PagePreviewSubAppTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

compile error / test failed
(tick)MODULES/repos/4-5-migrationinfo/magnolia/migration/task/general/AbstractPostMigrationTaskTest.javaorg.apache.log4j.Loggercompile error
info/magnolia/migration/task/general/IdCreationMigrationTaskTest.javaorg.apache.log4j.Logger
(tick)MODULES/repos/inplace-templatinginfo/magnolia/module/inplacetemplating/InplaceTemplatingModule.javaorg.apache.log4j.Loggercompile error
(tick)MODULES/groovy

using slf4j-simple (without proper exclusions), version no longer managed after upgrade
—trivial, pre-emptively removed slf4j-simple usage at all

poms

MODULES/repos/javascript-models - SMODELS-18

(info) PR ready

src/test/java/info/magnolia/module/jsmodels/rendering/JavascriptRenderingModelTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

org.apache.log4j.Level

compile error / test failed
(tick)

MODULES/repos/log-tools - LOGTOOLS-29

src/main/java/info/magnolia/log/tools/level/LogLevelSubApp.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / bug risk

src/main/java/info/magnolia/log/tools/level/LogLevelView.javaorg.apache.log4j.Levelbug risk
src/main/java/info/magnolia/log/tools/level/LogLevelViewImpl.javaorg.apache.log4j.Levelbug risk
src/main/java/info/magnolia/log/tools/level/model/LogLevelBean.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / bug risk
src/main/java/info/magnolia/log/tools/level/model/StringToLogLevelConverter.javaorg.apache.log4j.Levelbug risk
src/test/java/info/magnolia/log/tools/level/LogLevelSubAppTest.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed
(tick)

MODULES/repos/mail - MGNLMAIL-86

src/main/java/info/magnolia/module/mail/handlers/LoggingLevel.javaorg.apache.log4j.Levelbug risk
src/main/java/info/magnolia/module/mail/util/MailUtil.java

org.apache.log4j.Logger

compile error
(tick)

MODULES/repos/standard-templating-kit - MGNLSTK-1556

info/magnolia/module/templatingkit/util/SureFireModuleManager.java

org.apache.log4j.Logger

compile error
(tick)

PLATFORM/repos/main - MAGNOLIA-6794


src/main/java/info/magnolia/audit/LoggingLevel.javaorg.apache.log4j.Levelbug risk
magnolia-core/src/main/java/info/magnolia/audit/AuditLoggingManager.javaorg.apache.log4j.Loggercompile error
magnolia-core/src/test/java/info/magnolia/cms/filters/ContentTypeFilterTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/cms/security/RepositoryBackedSecurityManagerTest.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/logging/Slf4jSelfTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/module/model/reader/BetwixtModuleDefinitionReaderTest.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/setup/for5_0/AbstractNodeTypeRegistrationTaskTest.java

org.apache.log4j.Logger

org.apache.log4j.AppenderSkeleton

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/test/AbstractMagnoliaTestCase.java

org.apache.log4j.Logger

org.apache.log4j.Level

test failed
magnolia-core/src/test/java/info/magnolia/test/RepositoryTestCase.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed
magnolia-core/src/test/java/info/magnolia/test/TestUtil.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed
magnolia-rendering/src/test/java/info/magnolia/rendering/engine/RenderingFilterTest.java

org.apache.log4j.Logger

org.apache.log4j.WriterAppender

org.apache.log4j.SimpleLayout

compile error / test failed
magnolia-templating/src/test/java/info/magnolia/templating/functions/TemplatingFunctionsTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

org.apache.log4j.Level

compile error / test failed
(tick)

PLATFORM/repos/ui - MAGNOLIA-6794

magnolia-ui-form/src/test/java/info/magnolia/ui/form/field/factory/CompositeFieldFactoryTest.javaorg.apache.log4j.Leveltest failed
magnolia-ui-workbench/src/test/java/info/magnolia/ui/workbench/tree/HierarchicalJcrContainerTest.java

org.apache.log4j.Logger

org.apache.log4j.AppenderSkeleton

compile error / test failed
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/MediaEditorPresenterImpl.javaorg.apache.log4j.Loggercompile error
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/action/InstantMediaEditorAction.javaorg.apache.log4j.Logger
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/action/MediaEditorAction.javaorg.apache.log4j.Logger
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/action/MediaEditorUIAction.javaorg.apache.log4j.Logger
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/data/EditHistoryTrackingPropertyImpl.javaorg.apache.log4j.Logger
magnolia-ui-mediaeditor/src/main/java/info/magnolia/ui/mediaeditor/field/image/ImageMediaField.javaorg.apache.log4j.Logger


Other affected repos/projects


ModuleAffected FilesRemoveNote

MODULES/repos/magnolia-templating-compatibility (skip - project closed)src/test/java/info/magnolia/module/templating/paragraphs/JspParagraphRendererTest.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error /test failed

COOP/repos/cma-extranet (skip)cma-extranet-project-webapp/src/main/webapp/WEB-INF/config/default/log4j.dtdorg.apache.log4j.Level.dtd file

FORGE/repos/deadlink-appde/marvinkerkhoff/checker/LinkChecker.javaorg.apache.log4j.Loggercompile error
de/marvinkerkhoff/checker/PageLink.javaorg.apache.log4j.Logger
de/marvinkerkhoff/checker/TaskOverflowHandler.javaorg.apache.log4j.Logger
de/marvinkerkhoff/checker/TasksMonitorThread.javaorg.apache.log4j.Logger

FORGE/repos/google-analytics-demoinfo/magnolia/analyticsdemo/views/StatsViewImpl.javaorg.apache.log4j.Loggercompile error

FORGE/repos/site-verificationinfo/magnolia/module/siteverification/pages/SiteVerificationPage.javaorg.apache.log4j.Loggercompile error

INTEGRATION/repos/magnolia-magentoinfo/magnolia/magento/integration/app/browser/container/MagentoItemContainerProxy.javaorg.apache.log4j.Loggercompile error

INTEGRATION/repos/salesforce (skip)src/test/java/info/magnolia/salesforce/SalesForceModuleTest.java

org.apache.log4j.Logger

org.apache.log4j.EnhancedPatternLayout

org.apache.log4j.WriterAppender

compile error / test failed

INTERNAL/repos/openutils-log4j (skip)src/main/java/it/openutils/log4j/AlternateSMTPAppender.java

org.apache.log4j.AppenderSkeleton

org.apache.log4j.Level

compile error / test failed
src/main/java/it/openutils/log4j/Log4jConfigurationServlet.javaorg.apache.log4j.Leveltest failed
src/test/java/it/openutils/log4j/FilteredPatternLayoutTest.javaorg.apache.log4j.Loggercompile error

SERVICES/repos/deadlink-app-demode/marvinkerkhoff/checker/LinkChecker.javaorg.apache.log4j.Loggercompile error
de/marvinkerkhoff/checker/PageLink.javaorg.apache.log4j.Logger
de/marvinkerkhoff/checker/TaskOverflowHandler.javaorg.apache.log4j.Logger
de/marvinkerkhoff/checker/TasksMonitorThread.javaorg.apache.log4j.Logger

SERVICES/repos/magnolia-module-content-translation-support-extendinfo/magnolia/module/contenttranslationsupport/extend/common/helper/bundle/ExtTranslationBundleUpdater.javaorg.apache.log4j.Loggercompile error

SERVICES/repos/uzh - (skips)uzh-wcms-security/src/test/java/com/namics/uzh/wcms/security/aai/AAIUtilsTest.java

org.apache.log4j.Logger

org.apache.log4j.Level

compile error / test failed

SUPPORT/repos/quest-diagnosticsinfo/magnolia/module/mail/util/MailUtil.javaorg.apache.log4j.Loggercompile error

TELIASONERA/repos/mergejava/info/magnolia/merge/api/service/impl/DiffServiceImpl.javaorg.apache.log4j.Loggercompile error
com/pcloud/MyUI.javaorg.apache.log4j.Logger
com/pcloud/jcr_demo/NodeDiff.javaorg.apache.log4j.Logger
com/pcloud/jcr_demo/Utils.javaorg.apache.log4j.Logger
com/pcloud/jcr_demo/AppTest.javaorg.apache.log4j.Logger

Others refs to slf4j-simple


  • No labels