I want to create day dependent logfiles with log4j2
:
<
In yaml check the Property filePattern
defined as "${date:yyyy-MM-dd}"
, which helps to tag the date. If you are interested to tag the HOSTNAME
environment variable to date then : "${env:HOST}-${date:yyyy-MM-dd}"
Properties:
Property:
- name: log-path
value: "logs"
- name: filePattern
value: "${date:yyyy-MM-dd}"
Appenders:
Console:
name: Console_Appender
target: SYSTEM_OUT
PatternLayout:
pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
File:
name: File_Appender
fileName: "${log-path}/filelog-${filePattern}.log"
PatternLayout:
pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
RollingFile:
- name: RollingFile_Appender
fileName: "${log-path}/rollingfile-${filePattern}.log"
filePattern: "logs/archive/rollingfile.log.%d{yyyy-MM-dd-hh-mm}.gz"
PatternLayout:
pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"