This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j Configuration Issue

 
Saket Kumar Sinha
Ranch Hand
Posts: 32
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2988
59
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2988
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic