log4j2 - How to write logs to two different loggers? -
im able create 2 logs using log4j2 , im able write log single log file. how write logs 2 different loggers?
i modified log4j2.xml file have 2 loggers.
any sample example?
instead of configuring multiple loggers, may want configure multiple appenders. example:
<?xml version="1.0" encoding="utf-8"?> <configuration status="warn"> <appenders> <file name="myfile" filename="logs/app.log"> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> </file> <file name="other" filename="logs/other.log"> <patternlayout> <pattern>%d %p %c{1.} [%t] %m%n</pattern> </patternlayout> </file> </appenders> <loggers> <root level="trace"> <appenderref ref="myfile" level="trace"/> <appenderref ref="other" level="debug"/> </root> </loggers> </configuration>
Comments
Post a Comment