Hi normally in Log4j priority levels are as follows
- DEBUG < INFO < WARN < ERROR < FATAL
Can we change this priority levels.
My requirement is I need to log only details which have priority level INFO and FATAL. Logs with priority level DEBUG, WARN and ERROR shouldn't log. If I can change the priority levels as
- DEBUG < WARN < ERROR < INFO < FATAL
it is possible. Or is there any other way to do that. Pls help..
Best Answer
I was never needed to do this, but since I have once read Log4J - The Complete Manual, I hope these pointers will help.
Write following logic in decide
This filter will accept all the logs that are either INFO or FATAL. You may get more creative.
Please note that I have not tested this code. This is just a guideline, hope this helps
Edit: on a bit search, I found something that might be easier. I guess, You can use LevelMatchFilter, this way
refer: http://wiki.apache.org/logging-log4j/Log4jXmlFormat for XML configurarion. There is a section on
Filter Configuration
I don't know what stops OP in accepting this answer. I've just tested, it works:
Here is the XML.
Here is the Java code
Here is the output in (as configured)
D:/util.log