This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j HTMLLayout

 
levani dvalishvili
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I am trying to achive point when log file can be place within my applications "pages" directory
how would I achive that?
currently I have
and in this situation file gets created in start menu together with tomcat executables
is there any way without hard coding a path to fix this problem? since later I am going to port the application in linux based tomcat
[ March 13, 2005: Message edited by: levani dvalishvili ]
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a number of ways to handle this type situation. For example, using a build that produces properties file specific to each environment.

To use one log4j properties file, though, you can take advantage of the fact that log4j supports variable substitution either from system properties (or from variables defined in the properties file).

From PropertyConfigurator API Description:

All option values admit variable substitution. The syntax of variable substitution is similar to that of Unix shells. The string between an opening "${" and closing "}" is interpreted as a key. The value of the substituted variable can be defined as a system property or in the configuration file itself. The value of the key is first searched in the system properties, and if not found there, it is then searched in the configuration file being parsed. The corresponding value replaces the ${variableName} sequence. For example, if java.home system property is set to /home/xyz, then every occurrence of the sequence ${java.home} will be interpreted as /home/xyz.


So, for example you could start tomcat with a java -D param that would be picked up in the properties file:

java -Dpages.dir=/opt/mydir ...

log4j.appender.HFA2.file=${pages.dir}/htmlLayout.html
[ March 15, 2005: Message edited by: Carol Enderlin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic