java - how to print logs in tomcat servlet application -
i creating servlet on tomcat 6.0 in ubuntu 10.04. printing log used system.setout redirect output.
system.setout(new printstream(new file("/tmp/new.log"))); system.seterr(new printstream(new file("/tmp/new.log")));
i have use code in dopost() when run application not able see output thats why temporarily moved code in doget().
when hit url through browser http://127.0.0.1:8080/hello/hello getting following error on browser
java.security.accesscontrolexception: access denied (java.io.filepermission /tmp/new1.log read) java.security.accesscontrolcontext.checkpermission(accesscontrolcontext.java:342) java.security.accesscontroller.checkpermission(accesscontroller.java:553) java.lang.securitymanager.checkpermission(securitymanager.java:549) java.lang.securitymanager.checkread(securitymanager.java:888) java.io.file.exists(file.java:748) helloworldexample2.doget(helloworldexample2.java:42) javax.servlet.http.httpservlet.service(httpservlet.java:617) javax.servlet.http.httpservlet.service(httpservlet.java:717) sun.reflect.generatedmethodaccessor32.invoke(unknown source) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:616) org.apache.catalina.security.securityutil$1.run(securityutil.java:269) java.security.accesscontroller.doprivileged(native method) javax.security.auth.subject.doasprivileged(subject.java:537) org.apache.catalina.security.securityutil.execute(securityutil.java:301) org.apache.catalina.security.securityutil.doasprivilege(securityutil.java:162)**
i'd suggest using logging framework such log4j, slf4j or logging classes come java itself. you're kind of re-inventing wheel here :)
Comments
Post a Comment