This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes log4j HTMLLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
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: 1364
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://aspose.com/file-tools
 
subject: log4j HTMLLayout
 
Similar Threads
Reg Prototype file generation in Maven
database best practice
How to use Subscript in Struts2 Tags ?
Design problem
Reg:Component Resize