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

dynamic configuration of file appender

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a particular requirement in log4j. I want the user to be able to define virtually all aspects of a file appender (in this case a RollingFileAppender), except for the name and location of the log file. Ideally, I'd like the application to read the configuration file as normal, and then retrieve the file appender and override the filename for that appender. My configuration file looks as follows:



Now, in my main class, if look at which appenders are defined, I only see the CONSOLE appender (even though the log file is being written). The code I use to retrieve the appenders looks as follows:



Any idea why I'm not able to programmatically retrieve the FileOutput appender? Is there another better/simpler way to do what I'm trying to do?

Thanks.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your fileoutput appender isn't associated with the root logger, it is associated with your other logger in your xml file. When you get all the root logger's appenders it would not be in the list.

You can get it from that other logger.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic