[MAGNOLIA-6881] Switch to log4j2 Created: 22/Nov/16  Updated: 08/Sep/17  Resolved: 08/Sep/17

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Torsten Landmann Assignee: Unassigned
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates MAGNOLIA-6794 Upgrade log4j to v 2 Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:

 Description   

Magnolia still uses log4j although it has a severe performance bug in org.apache.log4j.Category:204 (method callAppenders()), namely the synchronized block there.
This bug effectively causes all log messages to be synchronized per category/logger, which means that ultimately all logging is synchronized in all reasonable scenarios somebody might run Magnolia in (including the Magnolia default configuration). This is because normally all log messages ultimately fall through to the root category, where they will be synchronized with each other.
Having synchronization at this stage not only defeats a lot of the advantages that asynchronous loggers (which you employ) could bring, it also means that multithreaded logging in advanced Magnolia apps substantially slows down everything, particularly since the synchronized block I'm talking about contains quite some code and spends some time per log message.

A natural improvement would be the switch to log4j2, which is already available in version 2.7. There is also a bridge available which allows you to use the conventional log4j code to create loggers (so you don't need to adapt each of cour classes before you can switch to log4j2).
I excluded log4j from your artifacts (in my pom.xml) and installed log4j2 including that bridge. The good news: Magnolia starts up. However two things obviously remain to be done:
1) rewrite log4j.xml (or write log4j2.xml for that matter) to reflect good defaults.
2) fix the Log Tools app in Magnolia (which currently throws exceptions when trying to run on log4j2, even with the bridge in place).



 Comments   
Comment by Mikaël Geljić [ 08/Sep/17 ]

Hi Torsten, thanks for reporting

Actually, we already have this item as MAGNOLIA-6794 in our backlog, and will be most likely switching to log4j2 in Magnolia 5.6.
Meanwhile, one of our partners documented how to start using it already on the community wiki:
https://wiki.magnolia-cms.com/display/WIKI/Upgrade+to+log4j2

I'll therefore close this ticket as duplicate.

Cheers,
Mika

Generated at Mon Feb 12 04:18:43 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.