Jetty 9.2下org.eclipse.jetty.NCSARequestLog,已被删除,无法找到该项类,网站访问需要通过org.eclipse.jetty.server.AsyncNCSARequestLog来处理。
修改方法:
找开jetty.home/etc/jetty.xml文件, 添加如下内容。
1) 添加请求处理LandlerRequestLogHandler
<Item>
<New id="RequestLog"class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
2)添加创建请求处理实例配置
<Ref id="RequestLog">
<Set name="RequestLog">
<New id="RequestLog"class="org.eclipse.jetty.server.AsyncNCSARequestLog">
<Setname="filename"><Property name="jetty.base"default="." /><Property>
<Name>jetty.requestlog.filePath</Name>
<Deprecated>requestlog.filename</Deprecated>
<Default><Propertyname="jetty.requestlog.dir"default="/logs"/>/yyyy_mm_dd.request.log</Default>
</Property>
</Set>
<Setname="filenameDateFormat"><Propertyname="jetty.requestlog.filenameDateFormat"deprecated="requestlog.filenameDateFormat"default="yyyy_MM_dd"/></Set>
<Setname="retainDays"><Propertyname="jetty.requestlog.retainDays"deprecated="requestlog.retain"default="90"/></Set>
<Setname="append"><Propertyname="jetty.requestlog.append" deprecated="requestlog.append"default="false"/></Set>
<Setname="extended"><Propertyname="jetty.requestlog.extended"deprecated="requestlog.extended"default="false"/></Set>
<Setname="logCookies"><Propertyname="jetty.requestlog.cookies"deprecated="requestlog.cookies"default="false"/></Set>
<Setname="LogTimeZone"><Propertyname="jetty.requestlog.timezone"deprecated="requestlog.timezone"default="GMT"/></Set>
</New>
</Set>
</Ref>
代码示例:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC"-//Jetty//Configure//EN""http://www.eclipse.org/jetty/configure_9_0.dtd">
<!--=============================================================== -->
<!-- Documentation of this file formatcan be found at: -->
<!--http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files areavailable in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.inifile for the default -->
<!-- configuration files. -->
<!-- -->
<!-- For a description of the configurationmechanism, see the -->
<!-- output of: -->
<!-- java -jar start.jar -? -->
<!--=============================================================== -->
<!--=============================================================== -->
<!-- Configure a Jetty Server instancewith an ID "Server" -->
<!-- Other configuration files may alsoconfigure the "Server" -->
<!-- ID, in which case they are addingconfiguration to the same -->
<!-- instance. If other configuration have a different ID,they -->
<!-- will create and configure anotherinstance of Jetty. -->
<!-- Consult the javadoc ofo.e.j.server.Server for all -->
<!-- configuration that may be sethere. -->
<!--=============================================================== -->
<Configure id="Server"class="org.eclipse.jetty.server.Server">
<Set name="handler">
<New id="Handlers"class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts"class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler"class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="RequestLog"class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<Ref id="RequestLog">
<Set name="RequestLog">
<New id="RequestLog"class="org.eclipse.jetty.server.AsyncNCSARequestLog">
<Setname="filename"><Property name="jetty.base"default="." /><Property>
<Name>jetty.requestlog.filePath</Name>
<Deprecated>requestlog.filename</Deprecated>
<Default><Propertyname="jetty.requestlog.dir"default="/logs"/>/yyyy_mm_dd.request.log</Default>
</Property>
</Set>
<Setname="filenameDateFormat"><Propertyname="jetty.requestlog.filenameDateFormat"deprecated="requestlog.filenameDateFormat"default="yyyy_MM_dd"/></Set>
<Setname="retainDays"><Propertyname="jetty.requestlog.retainDays"deprecated="requestlog.retain"default="90"/></Set>
<Setname="append"><Propertyname="jetty.requestlog.append" deprecated="requestlog.append"default="false"/></Set>
<Setname="extended"><Propertyname="jetty.requestlog.extended"deprecated="requestlog.extended"default="false"/></Set>
<Setname="logCookies"><Propertyname="jetty.requestlog.cookies"deprecated="requestlog.cookies"default="false"/></Set>
<Setname="LogTimeZone"><Propertyname="jetty.requestlog.timezone"deprecated="requestlog.timezone"default="GMT"/></Set>
</New>
</Set>
</Ref>
</Configure>