Spring Boot enable http requests logging (access logs)

前端 未结 4 741
谎友^
谎友^ 2020-12-05 04:18

How to enable access logs in an embedded tomcat server provided by spring boot? I\'ve tried this in application.properties but

4条回答
  •  情深已故
    2020-12-05 04:54

    With Spring Boot 2.X, if you want to manage Access logs, add these lines to your application.yml file:

    server:
      tomcat:
        basedir: /home/tmp
        accesslog:
          enabled: true
    

    It will create a folder named logs in the basedir you defined (/home/tmp here) containing the access log files.

    If you want to have access logs in the console do like that:

    server:
      tomcat:
        accesslog:
          enabled: true
          directory: /dev
          prefix: stdout
          buffered: false
          suffix:
          file-date-format:
    

    It will rediect logs to /dev/stdout

    More informations: https://community.pivotal.io/s/article/how-to-configure-access-log-entries-for-a-spring-boot-app?language=en_US

提交回复
热议问题