What is a Filepattern in Log4j 2 for?
16,897
Regarding the documentation:
The pattern of the file name of the archived log file. The format of the pattern is dependent on the RolloverPolicy that is used. The DefaultRolloverPolicy will accept both a date/time pattern compatible with SimpleDateFormat and/or a %i which represents an integer counter. The pattern also supports interpolation at runtime so any of the Lookups (such as the DateLookup can be included in the pattern.
Related videos on Youtube
Author by
Zion
Updated on July 22, 2022Comments
-
Zion almost 2 years
I have a question about The Filepattern for RollingFile Appender in log4j 2. The RollingFile needs an FileName and FilePattern but i dont know what the FilePattern does.I think it is just ignored. This a part of my log4j2.xml
<Property name="pattern"> %-5p [%d{dd.MM.yyyy - HH:mm:ss}] : %m%n %ex </Property> <Property name="MainLoggerPath"> C:/logs/MainLogger.log </Property> <Property name="FilePattern"> C:/logs/$${date:yyyy-MM}/app-%d{MM- dd-yyyy}-%i.log.gz </Property> <RollingFile name="MainAppender" fileName="${MainLoggerPath}" filePattern="${FilePattern}"> <ThresholdFilter level="ALL" onMatch="ACCEPT" onMismatch="DENY" /> <PatternLayout pattern="${pattern}" /> <Policies> <SizeBasedTriggeringPolicy size="10 MB" /> </Policies> <DefaultRolloverStrategy max="10" /> </RollingFile>