I couldn't find straight-forward solution via setting the right property in log4j.properties. However I can propose two solutions.
First, setting relative path in properties, makes that path relative not to the project (or jar), but the directory where you run your app from. So if you are creating for example a service which calls your jar, it will call it from /etc/init.d directory and your logs (most likely) will go nowhere.
One of the options is to set an environment variable, where you would like to have your logs. Log4j handles environment variables. Just set log4j.appender.file.File=${varname}
Another option, if you are using shell script to start your service/app/jar, cd to its directory before running it (assuming you have your path set log4j.appender.file.File=./logs/myOutput.log
). Something like this:
process="/path/to/your/jar/test.jar"
processName=`basename $process`
processDir=`dirname $process`
cd $processDir
java -jar "./$processName"
in this case your logs will be in /path/to/your/jar/logs/myOutput.log