protected Path resolveLog4j2()

in src/java/org/apache/turbine/Turbine.java [970:1008]


    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;
    }