Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Log4j Configuration Issue

 
Ranch Hand
Posts: 32
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!


 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic