工作纪实_29-SpringBoot启动配置使用jvm参数

JVM启动参数

-Djvm.log.path=/opt/service/myapp/logs

日志配置

Configuration:
  status: info
  monitorInterval: 30
  properties:
    property:
        name: log.path
        value: ${sys:jvm.log.path}
  Appenders:
    RollingFile:
     - name: error_file
       fileName: ${log.path}/error.log
       filePattern: "${log.path}/error_%d{yyyy-MM-dd}.log"
       PatternLayout:
         Pattern: "[%X{TRACE_ID}] %-d{yyyy-MM-dd HH:mm:ss} - [%p] [%C{1} %M] %m%n"
       Policies:
         TimeBasedTriggeringPolicy:
           interval: 1
           modulate: true
     - name: bus_file
       fileName: ${log.path}/bus.log
       filePattern: "${log.path}/bus_%d{yyyy-MM-dd}.log"
       PatternLayout:
         Pattern: "[%X{TRACE_ID}] %-d{yyyy-MM-dd HH:mm:ss} - [%p] [%C{1} %M] %m%n"
       Policies:
         TimeBasedTriggeringPolicy:
           interval: 1
           modulate: true
    Console:
      name: console
      target: SYSTEM_OUT
      PatternLayout:
        Pattern: "[%X{TRACE_ID}] %-d{yyyy-MM-dd HH:mm:ss} - [%p] [%C{1} %M] %m%n"
  Loggers:
    Root:
      level: info
      AppenderRef:
        -  ref: error_file
           level: ERROR
        -  ref: bus_file
           level: INFO
        -  ref: console
           level: debug

application.yml

server:
  port: 8115
  tomcat:
    accesslog:
      directory: ${jvm.log.path}/access
      enabled: true
      pattern: remote_addr=[%a] http_x_forward=[%{X-Forwarded-For}i] time=%t request=[%r] status=[%s] byte=[%b] elapsed=[%T] refer=[%{Referer}i] ua=[%{User-Agent}i] cookie=[]
      prefix: access_api
      suffix: .log

你可能感兴趣的:(工作纪实,jvm,spring,boot,java)