简体   繁体   English

使用xsbt-web-plugin请求Jetty容器的登录控制台

[英]Request log in console for Jetty container using xsbt-web-plugin

I'm using the xsbt-web-plugin to develop a webservice. 我正在使用xsbt-web-plugin开发Web服务。

For easier debugging I would like to switch on request logs in console like the line below. 为了简化调试,我想在控制台中打开请求日志,如下所示。

[22/Dez/2012:15:29:56 +0000] "GET /messages HTTP/1.1" 200 27276 [22 / Dez / 2012:15:29:56 +0000]“ GET / messages HTTP / 1.1” 200 27276

In production I'm using NCSARequestLog which is fine, but in development I would like to include the log in my sbt console where I started the container via container:start / 在生产中,我使用的是NCSARequestLog ,这很好,但是在开发中,我希望将日志包含在sbt console ,在sbt console ,我通过container:start /启动了容器

How can I enable the request logs? 如何启用请求日志?

To enable request logs, you can configure an NCSARequestLog via a custom jetty.xml file. 要启用请求日志,您可以通过自定义jetty.xml文件配置NCSARequestLog

Add this to build.sbt : 将其添加到build.sbt

env in Compile := Some(file(".") / "jetty-env.xml" asFile)

Create myproject/jetty-env.xml : 创建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 . 在sbt中,运行container:start ,您将看到在myproject / logs下收集的请求日志 When I tested this, Jetty would not create the logs directory on its own - I had to do that myself. 当我对此进行测试时,Jetty不会自己创建日志目录-我必须自己做。

You can watch the request log in real time with tail : 您可以使用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 . 有关此示例的完整示例,请参见xwp-templaterequest-logging分支

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 xsbt-web-plugin 的 xsbt 0.10.x 在构建期间无法找到 org.eclipse.jetty - xsbt 0.10.x using xsbt-web-plugin fails to find org.eclipse.jetty during build xsbt-web-plugin在sbt之外运行Webservelet容器? - xsbt-web-plugin Running the web servelet container outside of sbt? 使用xsbt-web-plugin时,为什么在Sbt控制台中检查compile:packageWar :: packagedArtifact失败? - Why does inspect compile:packageWar::packagedArtifact fail in the Sbt console when using xsbt-web-plugin? xsbt-web-plugin 中的 jetty:start 和 jetty:quickstart 有什么区别 - What is the difference between jetty:start and jetty:quickstart in xsbt-web-plugin 如何为xsbt-web-plugin指定jetty.xml配置文件 - How to specify a jetty.xml config file for xsbt-web-plugin 使用xsbt-web-plugin和JRebel时,SBT不会在webapp中传播更改 - SBT does not propagate changes in webapp when using xsbt-web-plugin and JRebel SBT从使用xsbt-web-plugin打包的war文件中排除scala-library.jar - SBT exclude scala-library.jar from a war file packaged using xsbt-web-plugin 使用xsbt-web-plugin配置Lift:查找主要方法类 - Configuring Lift with xsbt-web-plugin: finding the main method class 使用xsbt-web-plugin的多项目构建不打包WAR文件 - Multi-project build with xsbt-web-plugin not packaging WAR file 如何通过xsbt-web-plugin / merge application.conf包含每个Project Jar文件? - How to include per Project Jar file with xsbt-web-plugin / merge application.conf?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM