Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

log4j and file permissions  RSS feed

Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
We find this kind of rampant individuality very disturbing. But not this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!