• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

log4j.xml how to configure.

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I have logging working with my log4j.xml. The issue I have is, because ive moved over from .properties to .xml I need to add a few lines in to everything that has a logger.


Is there any way I can do the configuration without having to add these lines of code ? I tried moving the xml to the src folder and instead of giving me the warning bellow it logged nothing.

_______________________________________________________________________________
log4j:WARN No appenders could be found for logger (ProjectName).
log4j:WARN Please initialize the log4j system properly.
_______________________________________________________________________________


At the moment it works fine using the code above, but when I go to implement it in to my real application, it will take forever to add these 2 lines of code. I wondered if theres a way to have it configure the xml automatically?
 
Marshal
Posts: 27531
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The documentation says:

The preferred way to specify the default initialization file is through the log4j.configuration system property.



It goes on to say that once you have specified "log4j.configuration=log4j.xml", you should put log4j.xml somewhere in the classpath, just as you formerly did with log4j.properties.
 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:The documentation says:

The preferred way to specify the default initialization file is through the log4j.configuration system property.



It goes on to say that once you have specified "log4j.configuration=log4j.xml", you should put log4j.xml somewhere in the classpath, just as you formerly did with log4j.properties.



Hey Paul I understand this and I'm fine with that, my issue is I have to restart the server if I make changes to my log4j.xml. The only way I have found to work around it at the moment is to put this configuration in my code. I was wondering would something like log4jConfigListener, work and how would I implement this ? I'm currently not running log4j2 would this make a difference?
reply
    Bookmark Topic Watch Topic
  • New Topic