aspose file tools*
The moose likes Other Open Source Projects and the fly likes Get all categories defined in log4j.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Get all categories defined in log4j.xml" Watch "Get all categories defined in log4j.xml" New topic
Author

Get all categories defined in log4j.xml

James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
Hi All,

I need to get all the properties from log4j.xml

So, can anyone please help me out to solve this?

Thanks in advance!!!

Thanks
James
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

you can use getAllAppenders() to read information related to Appenders.

And getCurrentCategories( ) of Category class to get the categories defined.

Note that getCurrentCategories( ) is deprecated..

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#getCurrentCategories%28%29


- Chinna
James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
Chinna Eranna wrote:you can use getAllAppenders() to read information related to Appenders.

And getCurrentCategories( ) of Category class to get the categories defined.

Note that getCurrentCategories( ) is deprecated..

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#getCurrentCategories%28%29



Hi

Thanks for reply!!!

Here what I am doing is like



This is what I am doing to get categories from $JBOSS_HOME/server/default/conf/log4j.xml file.

As getCurrentCategories() method is deprecated I have used above code but it gives me object of org.apache.log4j.Logger not the category class objects

So, can anyone please do more focus into this?

Thanks
James
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

I dont see.. calling "getNextElement( )" on the enumeration object.
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

sorry.. typo..

getNextElement() ---> nextElement()
James Basller
Ranch Hand

Joined: Sep 07, 2008
Posts: 58
Chinna Eranna wrote:sorry.. typo..

getNextElement() ---> nextElement()



yes...

I have solved my mistake.

As getCurrentCategories() method is deprecated I have used above code but it gives me object of org.apache.log4j.Logger not the category class objects

so basically why I need this to get Enumeration of multiple categories and get priority of each and every category...

Can you please give me answer?

Thanks
James
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

Logger is a subclass of Category.

You can get all information from Logger, that you use to get from Category
 
jQuery in Action, 2nd edition
 
subject: Get all categories defined in log4j.xml