Jetty 9.2请求访问日志配置

 

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值