LOG 4J Classified by Level Level
Log4j is currently the industry standard for the current log, and its powerful and perfect features can meet most of our needs. Provide a perfect log processing method for our application system.
We know that the log level in log4j is divided into log, debug, info, warn, error, and Fatal six levels. Its flexible configuration mechanism is also a significant reason for LOG4J, which can be packaged, class, and root configuration. During my learning log4j, I used to be like log4j could not be classified according to Append. There is only one global, and then affects all Append. One disadvantage is to mix all the needs of the required logs, always not convenient when viewing and analyzing.
A few days ago, I downloaded a JIVE Forum, and suddenly found that his log processing system is based on the target, level classification, putting different log types into different places. I am very happy to open the JIVE release package to view, so I am a bit Disappointed is that jive uses its own log implementation, and does not use log4j. I think I find the way to handle this problem. If I don't have something I can modify some log4j's code, I always have this goal.
After a long time, I found a way of filtering, using the LevelMatchFilter class to work well. More unfortunately, use the Filter class, you must use the log4j.xml configuration method, from log4j.properties to XML is not difficult, let's refer to all XML configuration files:
XML Version = "1.0" encoding = "UTF-8"?>