aspose file tools*
The moose likes Beginning Java and the fly likes Log4j Configuration Issue 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 » Java » Beginning Java
Bookmark "Log4j Configuration Issue" Watch "Log4j Configuration Issue" New topic
Author

Log4j Configuration Issue

Saket Kumar Sinha
Ranch Hand

Joined: Aug 04, 2011
Posts: 32

I am trying to configure logger just for learning log4j.

I have log4j xml file like this

In the java code i am fetching this category


I have the main class which is calling the traceMessage and TraceDebugMessage as follows



My problem is
i have mentioned the category priorty as fatal in log4j xml.
and in the MyLogger class i am trying to print debug and warn like this.

objTraceLogger.warn(sbMessage);
objAlertLogger.debug(sbMessage.toString());

It should not have allowed as priority has been set for fatal only. But in the log file i am able to see the logs whenerver i am runnig the application.
What am i doing wrong here ?
Need Help!!


Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2315
    
  49
I've never used xml config files with Log4J I've always used properties files, but I had a quick look at the Log4jXmlFormat wiki and I can't see an element called category but there is one called logger which appears to have the same structure as your category elements. Are you sure the element is called category?
Saket Kumar Sinha
Ranch Hand

Joined: Aug 04, 2011
Posts: 32

Thanks tony for the reply

The above xml configuration is fine. we can use catalog to add multiple appenders as required.

The above code is working i saw some other logs and thought it's not working properly. wasted my time and effort.

Sorry !!


Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2315
    
  49
No problem.
To be honest I hadn't realised you could even use XML config files with Log4J and they look more readable than the property files I've been using so it has given me something to look into further.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Log4j Configuration Issue