File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes log4j HTMLLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "log4j HTMLLayout" Watch "log4j HTMLLayout" New topic
Author

log4j HTMLLayout

levani dvalishvili
Ranch Hand

Joined: Mar 01, 2005
Posts: 99
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 ]

SCJP 1.5(Done) SCJA 1.0(Done)<br />SCWCD(in Progress...)
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1348
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 ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: log4j HTMLLayout
 
Similar Threads
Design problem
database best practice
How to use Subscript in Struts2 Tags ?
Reg:Component Resize
Reg Prototype file generation in Maven