springboot中的access-log

 access-log 用于springboot查看连接数,访问IP、线程号、访问url、返回状态码、访问时间、持续时间
 在以往使用tomcat的过程中。tomcat 是会在logs下打印accesslog 的,来记录请求数,但是springboot内置的tomcat 默认情况下不打开。
 不过一般nignx上打印accesslog,开不开这个也无所谓

accesslog配置


server.tomcat.accesslog.enabled=true 默认是false
server.tomcat.accesslog.buffered=false
server.tomcat.accesslog.directory=E://mall1/logs
server.tomcat.accesslog.prefix=access_log
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd
server.tomcat.accesslog.pattern=%t [%I] %{X-Forwarded-For}i %a %r %q %s (%D ms) //默认值是common
 

引用配置

server.tomcat.accesslog.buffered=true # Buffer output such that it is only flushed periodically.
server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute.
server.tomcat.accesslog.enabled=false # Enable access log.
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in log file name.
server.tomcat.accesslog.pattern=common # Format pattern for access logs.
server.tomcat.accesslog.prefix=access_log # Log file name prefix.
server.tomcat.accesslog.rename-on-rotate=false # Defer inclusion of the date stamp in the file name until rotate time.
server.tomcat.accesslog.request-attributes-enabled=false # Set request attributes for IP address, Hostname, protocol and port used for the request.
server.tomcat.accesslog.rotate=true # Enable access log rotation.
server.tomcat.accesslog.suffix=.log # Log file name suffix.

更加详细的配置

技术交流群:809079777

Logo

华为云1024程序员节送福利,参与活动赢单人4000元礼包,更有热门技术干货免费学习

更多推荐