Closed
Description
Description
After DST time change in Chile , the logs are not showing the correct time with plain %d date pattern on September 8th but after midnight of 9th September the logs are printing correct date without having to change anything
but when we use date format with time zone it shows correct date on 8th September also .
Configuration
Version: 2.24
Operating system: RHEL
JDK: openJDK17
Logs
[Stacktraces, errors, etc. relevant applications logs.]
Reproduction
[An isolated test reproducing the test.
JUnit tests similar to the ones in the code base are extremely appreciated.]
Here’s the steps to reproduce it:
- Set the date on the server to September 8, with the time any time after 2am.
- Use a plain %d date format in log4j config file .
Here is the java code and config file :
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.TimeZone;
public class SimpleLog4jExample {
// Create a logger instance
private static final Logger logger = LogManager.getLogger(SimpleLog4jExample.class);
public static void main(String[] args) {
// Log messages of different levels
String tzid = "America/Santiago";
// tzid = readln("Enter time zone ID [" + tzid + "]: ", tzid);
TimeZone tz = TimeZone.getTimeZone(tzid);
TimeZone.setDefault(tz);
logger.info("This is an info message");
logger.warn("This is a warning message");
logger.error("This is an error message");
}
}
log4j2.xml