Hi,
Thanx for your suggestions.
In order to have the output stream and the error stream send
to a log file, I have made this servlet and it work (i think
:-)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class DebugJServ extends HttpServlet
{
PrintStream output;
PrintStream error;
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);
while (true)
{
synchronized(this)
{
try
{
wait(5000);
}
catch (InterruptedException e)
{
System.err.println(e);
}
}
output.flush();
error.flush();
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class DebugJServ extends HttpServlet
{
PrintStream output;
PrintStream error;
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);
while (true)
{
synchronized(this)
{
try
{
wait(5000);
}
catch (InterruptedException e)
{
System.err.println(e);
}
}
output.flush();
error.flush();
}
}
catch (IOException e)
{
System.err.println("Can't open the log files ");
}
catch (IOException e)
{
System.err.println("Can't open the log files ");
}
}
}
For this to work, you must add a "Debug" Zone
to your JServ engine then, the following lines to your jserv.properties
file:
# in the following path you will find your debug.properties
file
wrapper.classpath=C:\Program Files\Apache Group\Apache
JServ\conf
Debug.properties=C:\Program Files\Apache Group\Apache
JServ\conf\debug.properties
Your debug.properties will look like this
:
repositories=C:\Program Files\Apache Group\Apache\htdocs\Debug
repositories=C:\Program Files\Apache Group\Apache\htdocs\Debug
autoreload.classes=true
autoreload.file=true
init.timeout=10000
destroy.timeout=10000
session.timeout=1800000
session.checkFrequency=30000
singleThreadModelServlet.initialCapacity=5
singleThreadModelServlet.incrementCapacity=5
singleThreadModelServlet.maximumCapacity=10
servlets.startup=DebugJServ
You must also create a debuglog.properties
file :
# The path to the file for the standard output
outputFile=C:\\Program Files\\Apache Group\\Apache
JServ\\logs\\output.log
# The path to the file for the error
output
errorFile=C:\\Program Files\\Apache Group\\Apache
JServ\\logs\\error.log
The DebugJServ.class file must be put in the Debug
repository (e.g. : C:\Program Files\Apache
Group\Apache\htdocs\Debug )
Then you must stop and restart your servlet
engine.
Hope this will work for others.
One more time thanx to Rodrigo Zerlotti <[EMAIL PROTECTED]>
for its suggestion
Note: it works on NT, I think you must adapt your paths in order to make it
work on others machines.
Sven