How to replace category
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ah_ah
Posted On:   Thursday, December 12, 2002 12:24 AM

If i want to connect a category with a certain appender i use the category tag in my log4j.xml und appropiate code in my program.
Now category is "deprecated", using a logger object how can i join a logger with an appender?
At the moment i use





in the root section to add more than one appender to the root logger. but if i want to add more than one appender to another logger how can i do so?

Thanx for your help ...

Re: How to replace category

Posted By:   Anonymous  
Posted On:   Thursday, December 12, 2002 07:32 AM

The naming of the XML-Tags has nothing to do with the used Java-Class. So keep your log4j.xml. The javadoc of Category (Log4J 1.2) sais:
-----8-<------------8-<------------8-<------------8-<-------


This class has been deprecated and
replaced by the {@link Logger} 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 logger is a category. Thus,
all operations that can be performed on a category can be performed
on a logger. Whenever log4j is asked to produce a Category object,
it will instead produce a Logger object. However, methods that
previously 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 should be avoided.

-----8-<------------8-<------------8-<------------8-<-------

So your config file keeps. But use Logger instead of Category in your code.

About | Sitemap | Contact