Address: http://blog.csdn.net/caolaosanahnu/article/details/7553999
The following is written in the official log4j API, which is sufficient to explain the difference between logger and category:
-
-
public class Category
-
extends java.lang.Object
-
implements AppenderAttachable
This class has been deprecated and replaced byLogger
Subclass. It will be kept around to preserve backward compatibility until mid 2003.
Logger
Is a subclass of Category, I. e. it extends Category. In other words, a loggerIsA category. thus, all operations that can be performed med on a category can be performed med on a logger. internally, whenever log4j is asked to produce a Category object, it will instead produce a Logger object. log4j 1.2 willNeverProduce Category objects but onlyLogger
Instances. In order to preserve backward compatibility, methods that previusly accepted category objects still continue to accept category objects.
For example, the following are all legal and will work as expected.
// Deprecated form: Category cat = Category.getInstance("foo.bar") // Preferred form for retrieving loggers: Logger logger = Logger.getLogger("foo.bar")
The first form is deprecated and shoshould be avoided.
There is absolutely no need for new client code to use or refer toCategory
Class.Whenever possible, please avoid referring to it or using it.
See the short manual for an introduction on this class.
See the document entitled preparing for log4j 1.3 for a more detailed discussion.
-
Author:
-
Ceki gülc U, Anders Kristensen
========
This article is from the "cloud" blog, please be sure to keep this source http://tcloud.blog.51cto.com/4528333/1289843