• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get all categories defined in log4j.xml

 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont see.. calling "getNextElement( )" on the enumeration object.
 
Chinna Eranna
Ranch Hand
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry.. typo..

getNextElement() ---> nextElement()
 
James Basller
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Logger is a subclass of Category.

You can get all information from Logger, that you use to get from Category
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic