Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Apache Log4j Security Vulnerabilities - 2.17.0 jar not load Lookup values into log4j2.xml

As per Apache Log4j Security Vulnerabilities guideline i have updated 2.17.0 jar in my application.

Post upgrade Log files not getting generated.

Spring version : 5.3.13
Log4j version : 2.17.0
java : 1.8

Refer the given below log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="1">
    <Properties>
        
        <Property name="log-path">${appconfig:log_path}</Property>
        <Property name="log-name">${appconfig:filename}</Property>
        <Property name="archive-days">${appconfig:archive_days}</Property>
        <Property name="file-level">${appconfig:file_level}</Property>
        <Property name="console-level">${appconfig:console_level}</Property>
         
        
    </Properties>
    <Appenders>

        <Routing name="route-log">
            <Routes pattern="${ctx:routingLogFile}">
                
                <Route>
                    <RollingFile name="default-log" fileName="${log-path}/${log-name}.log"
                                 filePattern="${log-path}/${date:yyyy-MM}/${log-name}.%d{MM-dd-yyyy}-%i.log.gz" append="true">
                        <PatternLayout
                                pattern="%d{MM/dd/yyyy HH:mm:ss.SSS z} %X{machine-name} %X{app-name} [%t] %-5level %logger{36}:%-3L - %msg%n" />
                        <Policies>
                            <TimeBasedTriggeringPolicy />
                            <SizeBasedTriggeringPolicy size="150 MB"/>
                        </Policies>
                        <DefaultRolloverStrategy max="1000">
                            <Delete basePath="${log-path}/" maxDepth="2">
                                <IfFileName glob="/${log-name}*.log.gz" />
                                <IfLastModified age="${archive-days}" />
                            </Delete>
                        </DefaultRolloverStrategy>
                    </RollingFile >
                </Route>
        
            </Routes>
                
        </Routing>
        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{ISO8601} %-5level %30.30logger{1.}:%-3L - %m%n%throwable" />
        </Console>
    </Appenders>
    
    <Loggers>
        <Logger name="org.springframework" level="ERROR"/>
         <Logger name="org.apache" level="ERROR"/>
        <Root level="${file-level}" additivity="false">
            <AppenderRef ref="route-log" />
            <AppenderRef ref="STDOUT" />
        </Root>
    </Loggers>
    
</Configuration>

I am using given below lookup, in order to get the log file name , log file path ,log level,archive days from table.

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.lookup.AbstractLookup;
import org.apache.logging.log4j.core.lookup.StrLookup;
import org.appconfig.properties.ApplicationProperties;
import org.springframework.util.StringUtils;

@Plugin(name = "appconfig", category = StrLookup.CATEGORY)
public class AppLog4JConfigDatabaseLookup extends AbstractLookup {

    public String lookup(final LogEvent event, final String key) {
        
        
        if (key.equalsIgnoreCase("filename")) {
            return ApplicationProperties.getLogFilename();
        }
        if (key.equalsIgnoreCase("log_path")) {
            return ApplicationProperties.getLogPath();
        }
        if (key.equalsIgnoreCase("file_level")) {
            return ApplicationProperties.getFileLogLevel();
        }
        if (key.equalsIgnoreCase("console_level")) {
            return ApplicationProperties.getConsoleLogLevel();
        }
        if (key.equalsIgnoreCase("app_name")) {
            return ApplicationProperties.getAppName();
        }
        if (key.equalsIgnoreCase("archive_days")) {
            return ApplicationProperties.getLogArchiveDays();
        }
        
        return key;
    }
}

Refer the given below service class.

public class LoaderJob extends SchedulerAdapterJob {
    @Autowired
    private FileLoaderJob fileLoaderJob;
    
    private static final Logger LOGGER = LogManager.getLogger(LoaderJob.class);
    @Override
    public void executeJob(JobExecutionContext jobExecutionContext) {
        ThreadContext.put("routingLogFile","LOADER_LOGS");
        try {
            fileLoaderJob.execute();        
            
        }
        catch (Exception e) {
            LOGGER.error("Exception in  "+getJobName()+" : "+ e.getMessage());
            throw e;
        }
        finally {
              ThreadContext.remove("routingLogFile");
        }       
        
    }

}

its was working fine with 2.16.0 , not working in 2.17.0. Any solution would be appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As per Apache guideline, you should add two $ in routes pattern. But in your log4j2.xml contains only one

Refer the below link: https://logging.apache.org/log4j/log4j-2.2/faq.html

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!