Hi,
Sorry but there was a bug in the past servlet
that i sent you, the servlet engine was sometimes crashing.
Now, it works, this is the code, you must keep the same
config files.
import javax.servlet.*;
import
javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class DebugJServ extends
HttpServlet implements Runnable
{
PrintStream output;
PrintStream error;
Thread
runner;
public void
init(ServletConfig config) throws
ServletException
{
super.init(config);
InputStream is =
getClass().getResourceAsStream("/debuglog.properties");
Properties
debugProps = new
Properties();
try
{
debugProps.load(is);
}
catch (Exception e)
{
System.err.println("Can't read the properties file. " +
"Make sure debuglog.properties is in the
CLASSPATH");
return;
}
String outputFile
= debugProps.getProperty("outputFile", "output.log");
String errorFile =
debugProps.getProperty("errorFile", "error.log");
try
{
output = new
PrintStream(
new
BufferedOutputStream(
new FileOutputStream(outputFile)));
error = new
PrintStream(
new
BufferedOutputStream(
new FileOutputStream(errorFile)));
System.setOut(output);
System.setErr(error);
if (runner == null)
{
runner = new Thread(this);
runner.start();
}
}
catch
(IOException e)
{
System.err.println("Can't open the log file: ");
}
}
public void
stop()
{
if (runner !=
null)
runner =
null;
}
public void run()
{
Thread thisThread =
Thread.currentThread();
while (runner == thisThread)
{
try
{
Thread.sleep(1000);
}
catch
(InterruptedException e)
{
System.err.println(e);
}
output.flush();
error.flush();
}
}
}
Yours,
Sven