AmanDaharwal commented on issue #2185:
URL:
https://github.com/apache/logging-log4j2/issues/2185#issuecomment-1891774887
This is now working for me after using LoggerContext instead of
PropertyConfigurator.
```
LoggerContext context = (LoggerContext) LogManager.getContext(false);
File file = new File("./resources/log4j2.properties");
context.setConfigLocation(file.toURI());
```
But, now the challenge is log4j2.properties is unable to identify system
variable ${LOG_DIR} in below properties file -
```
status = warn
name= properties_configuration
# Give directory path where log files should get stored
property.basePath = ${LOG_DIR}
# ConsoleAppender will print logs on console
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.target = SYSTEM_OUT
appender.console.layout.type = PatternLayout
# Specify the pattern of the logs
appender.console.layout.pattern = %5p [%t] (%F:%L)- %m%n
# RollingFileAppender will print logs in file which can be rotated based on
time or size
appender.rolling.type = RollingFile
appender.rolling.name = fileLogger
appender.rolling.fileName= ${basePath}teswizSampleTestLog.log
appender.rolling.filePattern=
${basePath}teswizSampleTestLog_%d{yyyyMMdd}.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d - %c -%p - %m%n
appender.rolling.policies.type = Policies
# Configure root logger for logging error logs in classes which are in
package other than above specified package
rootLogger.level = info
rootLogger.additivity = false
rootLogger.appenderRef.rolling.ref = fileLogger
rootLogger.appenderRef.console.ref = consoleLogger
```
@vy any idea, how to make it work with LoggerContext or Configurator ?``
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]