I am currently creating a system that can have modules (think of them as plugins), where each one of them can have their own log, dedicated.
I would like to use the log4j2 project for logging, but I seem to have some trouble with the file appenders.
The main project (the module loader and "core" of the whole thing) should have its own log file, while the modules should have their own (like mod_XXXXXXXX.log
).
By reading the documentation about the appenders I discovered the FileAppender
class, and I was going to use that. Until I found out that I can't just simple add the appender to the default logger created by LogManager.getLog()
.
The logger returned by the LogManager is a different logger than the Logger
interface.
Even searching did not give me any near solution, all I found was predefined file logs in the xml configuration - which is not what I want.
Thank you for reading; even the slightest clue is welcome :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…