• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to read log4j.xml file path at runtime without hardcoding the path in Java Class...?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

In my project , I am using log4j.xml.
I need to get path of the log4j.xml at run time without hardcoding the path in Java Class.

My Scenario: I am reading the log4j.xml file and modifying the Appender and log levels and saving the changes in the log4j.xml.
I am able to do this using hard coding the path of the log4j.xml path in my Java Class .
But i need to do that dynamically without hard coding the log4j.xml file path.

Thanks
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your log4j.xml file simply needs to be dropped into the CLASSPATH, often if you are running on a web/app server they'll have a conf or deploy directory that is automatically added to the CLASSPATH your application is running on.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic