I would like to define a log configuration file that can:
- log DEBUG (and above) things in debug.log
- log INFO (and above) things in info.log
That is, when I call:
logger.warn("blah"); // Logs to both info.log and debug.log logger.debug("bleh"); // Logs to debug.log only
Is it possible?
I tried something like this, but it looks like when logback encounters several tags, it only accepts the last:
<appender name="infoFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${LOGS_FOLDER}/info.log</File> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <appender name="debugFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <File>${LOGS_FOLDER}/debug.log</File> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="INFO"> <appender-ref ref="infoFile" /> </root> <root level="DEBUG"> <appender-ref ref="debugFile" /> </root>
Here info.log contains debug level logs: (
Please note that I want to apply this behavior for each of my packages.
source share