Java:Spring启动Tomcat访问日志不是在Tomcat Start创建的

时间:2017-05-25 11:41:31

标签: java tomcat logging spring-boot

我想访问我的服务的tomcat日志,该日志是在具有嵌入式tomcat 8的spring boot中构建的。 我在我的服务bootstrap.yml中编写了以下代码。

server:
  port: 8320 
  context-path: /luggage-service
  tomcat:
   accesslog:
      directory: "/var/log/tomcat"
      enabled: true
      pattern: "{\"Hostname\":\"%h\", \"Logical username from identd\":\"%l\", \"Remote user\":\"%u\", \"Date&Time\":\"%t\", \"HTTP Status code\":\"%s\", \"Bytes Sent\":\"%b\", \"Time taken to process the request\":\"%D\", \"Local IPAdderss\":\"%A\", \"Local port\":\"%p\", \"Time taken to Commit the Request\":\"%F\", \"Request Method:%m User SessionID\":\"%S\", \"Requested URL path\":\"%U\", \"Local ServerName\":\"%v\"}"

当我构建并运行我的服务时,会创建一个文件"access_log.yyyy-mm-dd.log",当我点击我的服务调用时,就不会在日志文件中创建日志。 当我停止我的tomcat时会创建日志。 我的代码需要做哪些更改?

1 个答案:

答案 0 :(得分:0)

你可以尝试一下:

server.tomcat.accesslog.buffered=false