• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

DailyRollingFileAppender & Servlets with Tomcat

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
logging to the console works for me using log4j and servlets but when i make a slight modification to use a DailyRollingFileAppender I receive a security exception in tomcat's log files:


log4j:ERROR Could not create an Appender. Reported error follows.
java.security.AccessControlException: access denied (java.io.FilePermission mylog.txt write)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)



the rolling file appender seems to work from normal console apps. my config file looks like this:


i guess this is really a tomcat question but also.. if that were to work, what folder would the mylog.txt file be stored in? where can servlet's read and write from?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like your running Tomcat with a security manager.
If so, you may need to alter your security policy to allow writes to the specified file or diretory.
 
Ra Carter
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, so i tried editing the catalina.policy file by appending this to the end:



and then i'll issue a command like:
sudo /etc/init.d/tomcat5.5 restart

at which i point i notice that the line i wrote to the catalina.policy file has been erased anyway. i obviously don't know what i am doing here, any tips for me?

also is there anyway to use wildcards for this stuff? as in ${catalina.home}/**/log4j*.jar ?
[ July 07, 2007: Message edited by: ra carter ]
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pls try placing mylog.txt inside tomcat>>logs folder
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ra carter:




Its definitely a issue with the policy file.Change it as mentioned by Ra Carter.However try using a narrower permission to avoid AllPermission.

policy file you can fine in Tomcat's conf directory.

One more thing you might try is grant the permission to the file that is using log4j , not to the log4j jar itself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic