[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] NCSA request logging does not work for me
|
I am trying to get a jetty instance, that I set up programmatically,
to write an access log. This is the code I use:
public class FileServer
{
public static void main(String[] args) throws Exception
{
final InetSocketAddress serverAddress = new
InetSocketAddress("localhost", 8765);
Server server = new Server(serverAddress);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase("/Users/krueger/tmp");
final File logFile = new
File("/Users/krueger/Library/Logs/StreamingTest/access.log");
logFile.getParentFile().mkdirs();
final NCSARequestLog requestLog = new
NCSARequestLog(logFile.getAbsolutePath());
requestLog.setExtended(true);
final RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
requestLog.setAppend(true);
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, new
DefaultHandler(), requestLogHandler });
server.setHandler(handlers);
server.start();
server.join();
}
}
The server works as expected and the log file is created but no
requests are logged. The file remains empty. What am I missing?
Thanks in advance,
Robert