• 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

log4j - File Appenders..

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,..

Is there a way to have the log4j log file (declared in log4j.properties) within the web application - say WEB-INF/logs/example.log

I am not really sure how to give this relative path to file appenders in log4j.properties. My log4j.properties :



I appreciate your ideas on this.
Thanks again
 
Marshal
Posts: 28177
95
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
Using a "relative path" in a web application means relative to the application server's working directory. There's only one working directory for a JVM so it can't be related to any of the applications being run in the server. And that makes it useless for you.

You can put "${abc}" into a log4j configuration file and the configurator will replace that with the value of the "abc" Java system property. But again, system properties are one-per-JVM and not one-per-webapp so that probably isn't much more helpful.

Besides, if you put the logs into the web app then when you install a new WAR or EAR file, you lose all of those logs. You might want to consider logging to a fixed location outside of the application server.
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul Clapham

I think i will follow what you said - have the log file outside of the application server.
 
reply
    Bookmark Topic Watch Topic
  • New Topic