2017-05-25 74 views
0

我想訪問我的服務的tomcat日誌,它是在嵌入tomcat 8的spring引導中構建的。 我已經在我的服務的bootstrap.yml中編寫了以下代碼。Java:Spring引導Tomcat訪問日誌不是在Tomcat上創建的啓動

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時創建日誌。 我需要在我的代碼中做什麼更改?

回答

0

你能嘗試:

server.tomcat.accesslog.buffered=false 
+0

當我加入這個屬性緩衝,顯示一個警告,元數據屬性不會退出。所以我創建了額外的彈簧配置元數據,在META-INF中的json將這個屬性添加到元數據中。現在警告消失了,但是當tomcat停止時,日誌仍然會到來。 –