jQuery in Action, 3rd edition
The moose likes Other Open Source Projects and the fly likes log4j and file permissions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j and file permissions" Watch "log4j and file permissions" New topic

log4j and file permissions

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

This (big surprise) doesn't seem to be an issue at all on Windows, but on Linux (Slack 9) I can't get my log4j to work unless I do this:

chmod +777 my_debug_log.log

What's the minimum set of read/write permissions needed for log4j in a webapp environment? If I have this file inside /WEB-INF/logs/ shouldn't that file pickup the permissions/whatnot of its containing folders? When I start Tomcat as 'nobody' will log4j run as this user (for purposes of file permissions?)

Is there a big gap in my Unix file/directory permissions knowledge? (Ok, the answer to that last one is probably yes)
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Yes, log4j will be using the permissions for nobody. Write permissions on Unix are based on Owner and Owner group. So it actually depends on who owns the directory /WEB-INF/logs.
When you do a ls -al the permissions for the files and directories are list
drwxrwxrwx 2 root root 4096 Sep 9 05:38 .
drwxrwxr-x 11 root root 1024 Apr 2 08:16 ..
-rwxrwxrwx 1 root root 2003803 Sep 10 18:03 catalina.out
From left to right, d stands for of all things directory. The next 3 rwx means the Owner (root) has read write and execute permission. Next three are for members of the same group and the last three for everyone else.
Check to see who owns the logs directory and what permissions are on it you souldn't need more than rw for all three (666) actually better is to change the owner (chown) of the logs directory to nobody and change the permissions to 644. Once you have that, log4j should be able to log in that directory and create ehatever files it needs. I'd recommend the RollingFileAppender or the DailyFileAppender (I think that's the name one of those lookup things)

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
I agree. Here's the link: http://aspose.com/file-tools
subject: log4j and file permissions
It's not a secret anymore!