Re: Please help: JServ logging not solved yet
Andreas Tille wrote:
> OK, I could try that but what about the claiming that there is no
> method log() in GenericServlet? Looking into the definition of
> GenericServlet in the Servlet 2.1 API doc and also in GenericServlet.java
> i can see clearly its definition.
Humm I can't see log() method in class GenericServlet nor field log see:
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/GenericServlet.html
Clear, it's 2.2 API and you use 2.0 API.
[...thinking in progress...]
Arrg, Tom's solution may not work with servlet as System.setErr() and
System.setOut() call security manager as describe in
http://java.sun.com/products/jdk/1.2/docs/api/java/lang/System.html#setErr(java.io.PrintStream)
Let's try that class (not tested)
public class LogThruServlet extends PrintStream {
private GenericServlet gs;
public LogThruServlet (GenericServlet gs) {
/* dummy initialisation of super classes */
super (new OutputStream() {
public void write(int b) throws IOException {
/* Do nothing */
});
this.gs = gs;
}
public void print(String s) {
gs.log(s);
}
}
Then, in your servlet (may be in a constructor) add:
PrintStream log = new LogThruServlet (this);
System.setOut(log);
System.setErr(log);
Hope this help.
--
Edouard G. Parmelan
http://egp.free.fr
Reply to: