ank5
asked on
Specify log location using Log4j
I have a war file which uses log4j for logging.
Log4j.properties has the following for log file creation -
log4j.appender.fileAppende r.File=C:/ temp/MyApp lication.l og
The problem is that this war file is going to be deployed in Windows and Linux, so I don't want to hard code it to c:/temp.
Is there a way to provide this path in a generic way, say using some environment variables, java home, user directory etc.
Log4j.properties has the following for log file creation -
log4j.appender.fileAppende
The problem is that this war file is going to be deployed in Windows and Linux, so I don't want to hard code it to c:/temp.
Is there a way to provide this path in a generic way, say using some environment variables, java home, user directory etc.
Such config details should not be part of war file . Instead it should be in an external properties file , which would be read by one of your classes packaged into the war
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>on which server you are running this appl?
It's tcserver
It's tcserver
How is that relevant btw?
ASKER
log4j.appender.fileAppender.File=${u ser.home}/ MyApplicat ion.log
I tried this but it does not seem to work. Attached is how the log file looks like, is there something wrong in it?
Thanks
log4j.txt
ASKER
>>Such config details should not be part of war file . Instead it should be in an external properties file , which would be read by one of your classes packaged into the war
This isn't really an option for me. This log4j.properties is provided as a part of the product (Documentum xCP in this case), I can only modify it add logging for my custom classes.
This isn't really an option for me. This log4j.properties is provided as a part of the product (Documentum xCP in this case), I can only modify it add logging for my custom classes.
if you want a different path for windows and linux then you have to have something like configuration file that is different for windows and linux.
after reading this file at the beginning /before to initialize Log4J/ you can set the path properly in this way:
System.setProperty("logPat h", "the path specified in the config file");
then in your Log4J.properties file you have to have this:
log4j.appender.fileAppende r.File=${l ogPath}/yo urLogFile. out
after reading this file at the beginning /before to initialize Log4J/ you can set the path properly in this way:
System.setProperty("logPat
then in your Log4J.properties file you have to have this:
log4j.appender.fileAppende
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi CEHJ
Can you please try it with the log file that I had posted. I think that my log file may be incorrect.
Thank you
Can you please try it with the log file that I had posted. I think that my log file may be incorrect.
Thank you
That's what i did try it with (hence the same package name as yours) ;)
ASKER
There was a problem with the product, it was loading the wrong log4j.properties file, hence closing the question.
Thanks for your inputs.
Thanks for your inputs.
ASKER
The new package name structure is
com.lowagie.text.pdf.PdfWr iter;
It seems that they have completely refactored their API.
com.lowagie.text.pdf.PdfWr
It seems that they have completely refactored their API.
ASKER
-
ASKER
Please ignore the last two comments, they were posted in this question by mistake. I can't find an option to delete these comments.
Never mind :)
Open in new window