To enable request logs, you can configure an NCSARequestLog
via a custom jetty.xml file.
Add this to build.sbt:
env in Compile := Some(file(".") / "jetty-env.xml" asFile)
Create myproject/jetty-env.xml:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="handler">
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
<Set name="filename"><Property name="jetty.logs" default="./logs"/>/test-yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="LogTimeZone">GMT</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
</New>
</Set>
</New>
</Set>
</Configure>
In sbt, run container:start
, and you'll see request logs collected under myproject/logs. When I tested this, Jetty would not create the logs directory on its own - I had to do that myself.
You can watch the request log in real time with tail
:
tail -f myproject/logs/test-2013_08_23.request.log
For a full example of this, see the request-logging branch of xwp-template.