You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2026/07/20 11:42:00 UTC

[jira] [Resolved] (WW-5620) Replace java.util.logging and SLF4J with Log4j2

     [ https://issues.apache.org/jira/browse/WW-5620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-5620.
-------------------------------
    Resolution: Fixed

> 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
>            Priority: Trivial
>             Fix For: 7.3.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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)