Lukasz Lenart created WW-5620:
---------------------------------

             Summary: Replace java.util.logging and SLF4J with Log4j2
                 Key: WW-5620
                 URL: https://issues.apache.org/jira/browse/WW-5620
             Project: Struts 2
          Issue Type: Improvement
          Components: Core, Plugin - Tiles
            Reporter: Lukasz Lenart
             Fix For: 7.3.0


Struts 7 standardizes on Log4j2 as its logging layer, but three files still use 
legacy logging frameworks.

h3. java.util.logging (JUL) — 2 files in core

* {{core/src/main/java/org/apache/struts2/inject/ContainerBuilder.java}} — JUL 
{{Logger}} used in {{LOGGER_FACTORY}} (injects loggers via the DI container) 
and imported as a type
* 
{{core/src/main/java/org/apache/struts2/inject/util/FinalizableReferenceQueue.java}}
 — JUL {{Logger}} + {{Level}} used for error logging

h3. org.slf4j — 1 file in plugins/tiles

* 
{{plugins/tiles/src/main/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderable.java}}
 — SLF4J {{Logger}} + {{LoggerFactory}}

h3. What needs to change
* Replace {{java.util.logging.Logger}} / {{Level}} imports with 
{{org.apache.logging.log4j.LogManager}} / {{Logger}}
* Replace {{Logger.getLogger(name)}} with {{LogManager.getLogger(class)}}
* Replace {{Logger.getAnonymousLogger()}} with {{LogManager.getRootLogger()}}
* Replace {{logger.log(Level.SEVERE, msg, throwable)}} with {{logger.error(msg, 
throwable)}}
* Replace {{org.slf4j.LoggerFactory.getLogger()}} with 
{{LogManager.getLogger()}}

All three files contain code originally imported from external projects (Google 
Guice and Apache Tiles). No other classes inject {{java.util.logging.Logger}} 
from the container, so the migration is safe. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to