What should we use in jboss-log4j.xml in order to turn on/off traces for our product - "category" or "logger" tag?
By default JBoss uses "category" in jboss-log4j.xml.
But as far as I know "category" is deprecated and "logger" should be used instead.
Why JBoss uses deprecated "category" tag in a new product?
The "Category" groups sets of logger components. This way the level of all the logger components for a particular category can be controlled with a single log4j XML configuration[Have a set of logger statements grouped into a category. Each category can have a log level.]
In log4j a logger is associated with a package or sometimes with a particular class. Package/class of a logger is defined by the attribute "name". A logger logs messages in its package and also in all the child packages and their classes.
Logger is a subclass of Category, i.e. it extends Category. In other words, a logger is a category. Thus, all operations that can be performed on a category can be performed on a logger. Internally, whenever log4j is asked to produce a Category object, it will instead produce a Logger object.
JBoss AS uses log4j as logging framework. This tutorial will show how to configure log4j service in your jBoss application server and also how to create a custom configuration which can be deployed along with your application. Log4j is a flexible open source project from Apache.
Habit, I suspect. I still to use category also. It behaves exactly the same as logger, there really is no difference.
category in the log4j.xml (not limited to jboss-log4j.xml) is common practice and its not deprecated. What got deprecated is the Category Class as in usage of Category in code like,
Category category = Category.getInstance('something');
In log4j.xml, both category and logger can be used. Probably the newer code will have the logger in log4j.xml. Old way is category.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With