What is the difference between log4j. rootLogger and log4j. rootCategory in log4j. properties?

Source: Internet
Author: User

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 byLoggerSubclass. It will be kept around to preserve backward compatibility until mid 2003.

LoggerIs 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 onlyLoggerInstances. 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 toCategoryClass.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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.