【配置jetty访问日志提示:Exception in thread "main" _jetty/tomcat 】 | IT修真院·坑乎
问题已收录 配置jetty访问日志提示:Exception in thread "main"
我也踩过这个坑( 1 )
已统计您的踩坑,无需重复点击
回答(1)
jetty/tomcat
详细描述
错误截图
源码
编辑于2024-05-19
  • [无名弟子]张高愿
    0

    jetty官方有关于访问日志的配置文档,可以参考一下,附上链接

    https://wiki.eclipse.org/Jetty/Tutorial/RequestLog


    Configuring Request Log

    To configure a single request log for the entire Jetty Server instance:

    <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="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
          <Arg><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Arg>
          <Set name="retainDays">90</Set>
          <Set name="append">true</Set>
          <Set name="extended">false</Set>
          <Set name="LogTimeZone">GMT</Set>
        </New>
      </Set></Ref>

    The equivalent code is:

    HandlerCollection handlers = new HandlerCollection();ContextHandlerCollection contexts = new ContextHandlerCollection();RequestLogHandler requestLogHandler = new RequestLogHandler();handlers.setHandlers(new Handler[]{contexts,new DefaultHandler(),requestLogHandler});server.setHandler(handlers); 
    NCSARequestLog requestLog = new NCSARequestLog("./logs/jetty-yyyy_mm_dd.request.log");requestLog.setRetainDays(90);requestLog.setAppend(true);requestLog.setExtended(false);requestLog.setLogTimeZone("GMT");requestLogHandler.setRequestLog(requestLog);

    This configures a request log in $JETTY_HOME/logs with filenames including the date. Old log files are kept for 90 days before being deleted. Existing log files are appended to and the extended NCSA format is used in the GMT timezone.

    There are many more configuration options available - see NCSARequestLog.java


    编辑于2018-12-21