Sharon
Sharon

Reputation: 11

Set log4j output log file underneath my project Not eclipse

I use Eclipse as my IDE to develop my project. The log have been output to myproject/logs/log.log as I expected, until I did some setting that I saw from some web site.

I went to Windows -> preferences -> Java -> Build Path -> Classpath Variable to add the "log4j-1.2.16.jar".
Since then, the log file started showing under D:\eclipse\logs\ instead of D:\workspace\MyProject\logs.

I have deleted the classpath variable entry and restart Eclipse, but I just cannot have the log file created under my project anymore.

Help!!! Thanks.

Upvotes: 1

Views: 5005

Answers (2)

Jens Schauder
Jens Schauder

Reputation: 81988

I think the log file location (if not an absolute path) is relative to the working directory of your app. You can set the working directory of your application in the run configuration:

Run -> Run Configuration -> Arguments Tab

in the lower part of the screen you can set your working directory

Upvotes: 0

cherouvim
cherouvim

Reputation: 31928

It's best if you explictly define the path where the log should go. For example if this is a webapp deployed on tomcat you can:

log4j.appender.YOURLOG.file=${catalina.home}/logs/my-application.log

Upvotes: 1

Related Questions