What is the difference between log4j. rootlogger and log4j. rootcategory?

Source: Internet
Author: User
Tags deprecated
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.

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
Synchronized med on a logger. Internally, whenever log4j is asked
Produce a category object, it will instead produce a logger
Object. log4j 1.2 willNeverProduce category objects
OnlyLoggerInstances. In order to preserve backward
Compatibility, methods that previously accepted category objects
Still continue to accept category objects.

For example, the following are all legal and will work
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
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

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.