I use log4j2 in my project something like this:
logger.log(Level.ERROR, this.logData);
My configuration file looks like this:
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="ERROR" DLog4jContextSelector="org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"> <Appenders> <RandomAccessFile name="RandomAccessFile" fileName="C:\\logs\\log1.log" immediateFlush="false" append="false"> <PatternLayout> <Pattern>%d %p %c{1.} [%t] %m %ex%n</Pattern> </PatternLayout> </RandomAccessFile> </Appenders> <Loggers> <Root level="error" includeLocation="false"> <AppenderRef ref="RandomAccessFile"/> </Root> </Loggers>
It creates my file, I write something to it, but it is still empty. When I try to delete this file, the OS told me that it is being used (if the application is currently running), but even if I stop the application, the file is still empty.
So, what settings should be changed so that they work correctly?
source share