I spent a couple of days to figure out a way to use log4j to log into two different files with YAML configuration file. Is it possible?
I have gone through similar questions with properties file and some blog posts, given below.
I have a configuration file like this:
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO
# Logger-specific levels.
loggers:
# Sets the level for 'com.appraptorsors.herotemps' to DEBUG.
com.company.project: DEBUG
appenders:
- type: console
threshold: ALL
- type: file
threshold: ALL
currentLogFilename: /home/assets/logs/_1.log
archivedLogFilenamePattern: ./logs/archive-%d.log.gz
archivedFileCount: 5
# The timezone used to format dates. HINT: USE THE DEFAULT, UTC.
timeZone: UTC
How can i configure this as explained in this accepted answer here? This is exactly what I'm looking for - two loggers invoked by separate handlers. Another reference is here.
My log4j version is 1.2.17 and it's fine to upgrade it.
Any help is much appreciated.