In my last memo about how to use logback in Akka to log into file system, I showed the way to config logback.xml.
However, recently I find it killing me when I use this log file for bug-shooting, because all the log, including debug, info, warning, error are all in one file. And what I am really looking for is error, which is really rare in the log file.
So, it seems reasonable to place logs of different level into different files. In my case, which would also cover most cases, I will place all the info log line into info.log, and all the error log and above to the error.log.
Since we are place log into different files, we are going to use multiple appenders.
To put info log one file
The key point is in the filter element. This filter uses LevelFilter to decide which level of log should be logged.
To put error and all levels above to another file
In this example, we use ThresholdFilter to select all the levels above the error to log file.
Then, put two appenders together
This is the tricky part. We ganna use two root logger in the same logback.xml.