Question

I'm trying to run Jetty on CentOS and am having problems as I am getting unexpected results when I try to set the full path for JETTY_LOGS. The system tries to take that path and append it to the path I specified in the JETTY_HOME variable.

JETTY_HOME=/usr/local/jetty/jetty-9.1.4
JETTY_USER=jetty
JETTY_PORT=8085
JETTY_HOST=0.0.0.0
JETTY_LOGS=/usr/local/jetty/jetty-9.1.4/logs

Any ideas as to what I'm doing wrong?

The error I get is:

Starting Jetty: java.io.IOException: Cannot write start.log to directory
/usr/local/jetty/jetty-9.1.4/usr/local/jetty/jetty-9.1.4/logs [directory doesn't exist or is read-only]
java.io.IOException: Cannot write start.log to directory /usr/local/jetty/jetty-9.1.4/usr/local/jetty/jetty-9.1.4/logs [directory doesn't exist or is read-only]
        at org.eclipse.jetty.start.StartLog.initLogFile(StartLog.java:127)
        at org.eclipse.jetty.start.StartLog.initialize(StartLog.java:113)
        at org.eclipse.jetty.start.Main.processCommandLine(Main.java:520)
        at org.eclipse.jetty.start.Main.main(Main.java:102)
Was it helpful?

Solution

It seems that JETTY_LOG directory is relative to JETTY_HOME.

Could you try to set:

 JETTY_LOGS=/logs

or alternatively

 JETTY_HOME=/usr/local/jetty/jetty-9.1.4/
 JETTY_LOGS=logs

OTHER TIPS

You're not doing anything wrong, this is new behavior in jetty 9.1.4:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=432192

Workaround is to set the JETTY_LOGS env var relative to your jetty base dir (like the logs dir that comes in the standard jetty tarball):

JETTY_LOGS=logs

Which will resolve to /usr/local/jetty/jetty-9.1.4/logs in your case (the jetty base dir defaults to the jetty home dir).

If you want the logs written somewhere outside of your jetty base dir, the best way is to use the above JETTY_LOGS=logs env setting, and just symlink the dir elsewhere; like this to create and link to the common /var/log/jetty dir:

# mv /usr/local/jetty/jetty-9.1.4/logs /var/log/jetty
# ln -s /var/log/jetty /usr/local/jetty/jetty-9.1.4/logs

Whatever you do, also make sure that the user as which you run jetty has write access to the logs dir; if you use the jetty user in the jetty group, make it the owner of your logs dir:

# chown -R jetty:jetty /var/log/jetty
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top