vy commented on issue #2185:
URL:
https://github.com/apache/logging-log4j2/issues/2185#issuecomment-1891626589
In your `log4j2.properties`, the following block is problematic:
```
rootLogger.level = info
rootLogger.appenderRefs = console, rolling
rootLogger.appenderRef.console.ref = STDOUT
rootLogger.appenderRef.rolling.ref = RollingFile
# The root logger with appender name
rootLogger = INFO, STDOUT
```
The last line overrides the first block – `RollingFile` appender disappears.
I have refactored your configuration below.
Given this `Log4j2Issue2185.properties`
```
status = WARN
property.fileNamePrefix = ${sys:LOG_DIR}/Log4j2Issue2185
appender.console.type = Console
appender.console.name = CONSOLE
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss,SSS}] %-5p
[%c.%M()] (%t) %m%n
appender.rolling.type = RollingFile
appender.rolling.name = ROLLING
appender.rolling.fileName = ${fileNamePrefix}.log
appender.rolling.filePattern = ${fileNamePrefix}-%d{MM-dd-yy-HH-mm-ss}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss,SSS}] %-5p
[%c.%M()] (%t) %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 2
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 5
rootLogger.level = INFO
rootLogger.appenderRef.$1.ref = CONSOLE
rootLogger.appenderRef.$2.ref = ROLLING
```
Following `Log4j2Issue2185.java` works for me:
```
package ci.yazi.volkan;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Log4j2Issue2185 {
static {
System.setProperty("LOG_DIR", "/tmp");
System.setProperty("log4j.configurationFile",
"Log4j2Issue2185.properties");
}
private static final Logger LOGGER = LogManager.getLogger();
public static void main(String[] args) {
LOGGER.info("INFO ->>>>>>>>>>>>>>>");
LOGGER.trace("TRACE ->>>>>>>>>>>>>>>");
LOGGER.debug("DEBUG ->>>>>>>>>>>>>>>");
LOGGER.warn("WARN ->>>>>>>>>>>>>>>");
LOGGER.fatal("FATAL ->>>>>>>>>>>>>");
LOGGER.error("ERROR ->>>>>>>>>>>>>>");
}
}
```
**I need you to share a similar Java file reproducing the issue you are
describing.**
> Also, using the PropertyConfigurator to configure both files
Why? This is a Log4j 1 configurator. Can't you use it the way I exemplified
above, i.e., using `System.setProperty("log4j.configurationFile",
"Log4j2Issue2185.properties")`?
--
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]