This is an automated email from the ASF dual-hosted git repository.

tv pushed a commit to branch system-logger
in repository https://gitbox.apache.org/repos/asf/turbine-core.git

commit 706d7f411ddf90ca5f7bd9051eb1fa322deebf6e
Author: Thomas Vandahl <[email protected]>
AuthorDate: Thu Jan 22 15:55:52 2026 +0100

    Remove explicit log4j configuration,
    
    provide init parameter for log4j-jakarta-web instead
---
 src/java/org/apache/turbine/Turbine.java | 88 ++------------------------------
 1 file changed, 3 insertions(+), 85 deletions(-)

diff --git a/src/java/org/apache/turbine/Turbine.java 
b/src/java/org/apache/turbine/Turbine.java
index a6f3e546..a4a1e86a 100644
--- a/src/java/org/apache/turbine/Turbine.java
+++ b/src/java/org/apache/turbine/Turbine.java
@@ -40,8 +40,6 @@ import 
org.apache.commons.configuration2.io.HomeDirectoryLocationStrategy;
 import org.apache.commons.lang3.NotImplementedException;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.turbine.log.Log;
 import org.apache.turbine.modules.PageLoader;
 import org.apache.turbine.pipeline.Pipeline;
@@ -113,7 +111,8 @@ import jakarta.xml.bind.Unmarshaller;
  */
 @WebServlet(name = "Turbine", urlPatterns = { "/app" }, loadOnStartup = 1, 
initParams = {
         @WebInitParam(name = TurbineConstants.APPLICATION_ROOT_KEY, value = 
TurbineConstants.APPLICATION_ROOT_DEFAULT),
-        @WebInitParam(name = TurbineConfig.PROPERTIES_PATH_KEY, value = 
TurbineConfig.PROPERTIES_PATH_DEFAULT) })
+        @WebInitParam(name = TurbineConfig.PROPERTIES_PATH_KEY, value = 
TurbineConfig.PROPERTIES_PATH_DEFAULT),
+        @WebInitParam(name = "log4jConfiguration", value = 
TurbineConstants.LOG4J2_CONFIG_FILE_DEFAULT) })
 @MultipartConfig
 public class Turbine extends HttpServlet
 {
@@ -306,12 +305,7 @@ public class Turbine extends HttpServlet
         // /WEB-INF/conf/TurbineResources.properties relative to the
         // web application root.
 
-        Path confPath = configureApplication(config, context);
-
-        configureLogging(confPath);
-
-        //
-        // Logging with log4j 2 is done via convention, finding in path
+        configureApplication(config, context);
 
         setTurbineServletConfig(config);
         setTurbineServletContext(context);
@@ -929,82 +923,6 @@ public class Turbine extends HttpServlet
         serverData = (ServerData) requestServerData.clone();
     }
 
-    /**
-     * Checks Log4j 2 Context, loads log4File, if configured and configuration
-     * is not already located.
-     *
-     * @param logConf
-     *            Configuration file path
-     * @throws IOException
-     *             if path not found
-     */
-    protected void configureLogging(Path logConf) throws IOException
-    {
-        LoggerContext context = (LoggerContext) LogManager.getContext(false);
-
-        if (context.getConfiguration().getConfigurationSource().getLocation() 
== null)
-        {
-            Path log4jFile = resolveLog4j2(logConf.getParent());
-            // configured + no other log4j configuration already found
-            if (log4jFile != null)
-            {
-                org.apache.logging.log4j.spi.LoggerContext ctxContext = 
LogManager.getContext(null, false, log4jFile.toUri());
-                if (ctxContext instanceof LoggerContext)
-                {
-                    log.info("resolved log4j2 location: {0}", 
context.getConfiguration().getConfigurationSource().getLocation());
-                }
-
-            }
-        }
-        log.info("found log4j2 location: {0}", 
context.getConfiguration().getConfigurationSource().getLocation());
-    }
-
-    /**
-     * Check {@linkplain TurbineConstants#LOG4J2_CONFIG_FILE} in Turbine
-     * configuration.
-     *
-     * @param logConfPath
-     *            configuration directory
-     * @return Resolved log4j2 {@link Path} or null, if not found or configured
-     *         "none".
-     */
-    protected Path resolveLog4j2(Path logConfPath)
-    {
-        String log4jFile = 
configuration.getString(TurbineConstants.LOG4J2_CONFIG_FILE,
-                TurbineConstants.LOG4J2_CONFIG_FILE_DEFAULT);
-
-        if (log4jFile.startsWith("/"))
-        {
-            log4jFile = log4jFile.substring(1);
-        }
-        Path log4jTarget = null;
-        if (StringUtils.isNotEmpty(log4jFile) && 
!log4jFile.equalsIgnoreCase("none"))
-        {
-            // log4j must either share path with configuration path or resolved
-            // relatively
-
-            if (logConfPath != null)
-            {
-                Path log4jFilePath = Paths.get(log4jFile);
-                Path logFilePath = logConfPath.resolve(log4jFilePath);
-                if (logFilePath != null && logFilePath.toFile().exists())
-                {
-                    log4jTarget = logFilePath.normalize();
-                }
-                else // fall back just using the filename, if path match
-                if (log4jFilePath != null && log4jFilePath.getParent() != null 
&& logConfPath.endsWith(log4jFilePath.getParent()))
-                {
-                    logFilePath = 
logConfPath.resolve(log4jFilePath.getFileName());
-                    if (logFilePath != null && logFilePath.toFile().exists())
-                    {
-                        log4jTarget = logFilePath.normalize();
-                    }
-                }
-            }
-        }
-        return log4jTarget;
-    }
-
     /**
      * Set the application root for the webapp.
      *

Reply via email to