Java:Spring引导Tomcat访问日志不是在Tomcat启动时创建的
我想访问我的服务的tomcat日志,该服务是在spring boot中构建的,其中嵌入了tomcat 8。 我已经在我的服务的Java:Spring引导Tomcat访问日志不是在Tomcat启动时创建的,java,tomcat,logging,spring-boot,Java,Tomcat,Logging,Spring Boot,我想访问我的服务的tomcat日志,该服务是在spring boot中构建的,其中嵌入了tomcat 8。 我已经在我的服务的bootstrap.yml中编写了以下代码 server: port: 8320 context-path: /luggage-service tomcat: accesslog: directory: "/var/log/tomcat" enabled: true pattern: "{\"Hostname\":\
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.yyy-mm-dd.log”
,当我调用我的服务时,则不会在日志文件中创建任何日志。
日志是在我停止tomcat时创建的。
我需要在代码中做哪些更改?您可以试试:
server.tomcat.accesslog.buffered=false
当我添加此缓冲属性时,会显示一条警告,说明元数据属性不存在。因此,我在META-INF中创建了额外的spring配置元数据json,以便在元数据中添加此属性。现在警告已经消失,但当tomcat停止时,日志仍然会出现。