java - Log4j, how to put log file into dynamic directory location -


can show me how can put log file log4j in project location? want put log file src/main/resources every time. don't want care me location on disk of project, sample: if have project in d:/project , after change location project in c:/project want put log file on every time on src/main/resources out change line

log4j.appender.file.file=c:\\project 

with this

log4j.appender.file.file=d:\\project 

have idea? thx in advance :)

you can write logic determine if application being run in c:\... or d:\... retrieving current directory , set system variable "logpath" below

system.setproperty("logpath", mypath); // mypath either c:\... or d:\... based on logic 

then use property in log4j.properties

log4j.appender.file.file=${logpath}src\main\resources\myapplicationlog.log 

note : need make sure system variable set before log4j initialized.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -