I am working on logging for Java and using log4j for the same. This is my config file for FileRollOver
status = warn
property.filename = $${date:YYYY-MM-dd}
# Rotate log file
appender.rolling.type = RollingFile
appender.rolling.name = LogToRollingFile
appender.rolling.fileName = ../app_log/service/app-java-${date:YYYY-MM-dd}.log
appender.rolling.filePattern = app_log/service/app-java-${date:YYYY-MM-dd}.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} [%-5p] %M: %m%n
appender.rolling.policies.type = Policies
#appender.rolling.policies.time.type = OnStartupTriggeringPolicy
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval=1
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.size=10MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 10
#logger specific configuration
loggers
logger.name=rolling
logger.additivity = true
logger.appenderRefs = rolling
logger.appenderRef.rolling.ref = LogToRollingFile
logger.appenderRef.rolling.stdout.ref = STDOUT
#root logger configuration
rootLogger.level = INFO
#rootLogger.appenderRef.stdout.ref = LogToConsole
rootLogger.appenderRef.stdout.ref = LogToRollingFile
The config is like a new file for logs should be created each new day. But when I am running it is throwing me this exception.
2023-05-05 14:37:39,819 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: Pattern does not contain a date java.lang.IllegalStateException: Pattern does not contain a date
and
2023-05-05 14:37:39,823 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
Though my file name has date in it but it is not working out anyway. What could go wrong? PS: I am using IntelliJ Idea as IDE and it is a Gradle project.