Skip to content

Config example

Shawn Clovie edited this page Dec 26, 2019 · 5 revisions
# 应用名称,用于statsd的prefix、fluent的tag等处
app_name: MyAwesomeApp

# 定义所有的Logger
log:
  # 默认logger
  # 当使用rock.Logger(name)且没有对应的logger时,将返回默认logger,此处对它进行设置
  default:
  # logger名
  # 在Application.Init中自动创建,并由rock.Logger("LoggerA")获得
  User:
    # 定义该logger的各种输出方式,此处以log.handlers中的设置为基础,建立相应的log handler
    # 各handler的level缺省为debug
    console:
      level: debug # debug(默认) | info | warn | error | fatal
      stream: stdout # stdout(默认) | stderr
      format: text # text(默认) | json
      # optional,要包含在log中的部分
      # 文本模式下,非空串即为输出该部分内容
      # json模式下,意为该部分内容在对象中的key
      keys: {message: M,time: T,level: L,name: N,caller: C}
      time_format: iso8601 # iso8601 | seconds | millis | nanos
    # 输出至文件
    file:
      format: text # text(默认) | json
      location: # 相对或绝对路径
      rotation: {...} # 格式与目前版本相同
      encoding: utf-8 # 默认utf-8
      keys: ... # 与console相同
      time_format: ... # 与console相同
      level: error
    # 输出至fluent
    # 此部分设置不可带有host, port, async等用于初始化fluent的设置
    fluent:
      host: bytepower-nlb-stage-23904230409fdsaf.elb.us-east-1.amazonaws.com
      port: 24224
      async: true # 是否异步初始化和记录数据
      tag: # 发送的消息的标记,并以app_name作为前缀
      level: info
  Access:
    file:
      location: output/access
      rotation: ...
    fluent:
      host: bytepower-nlb-stage-23904230409fdsaf.elb.us-east-1.amazonaws.com
      port: 24224
      async: true # 是否异步初始化和记录数据
      tag: access
  Boost:
    console:
  # 其它自定义的Logger
  ...
# stats的设置,源于statsd.Option
metric:
  # stats服务的地址
  host: "127.0.0.1:8125"
  # 以下配置皆为可选
  
  max_packet_size: 10 
  # 自动flush的间隔秒数,若设为0则仅当缓存满时才flush
  flush_period_seconds: 10
  # 网络协议类型 udp | tcp | 其它
  network: tcp
  mute: false
  # SampleRate sets the sample rate of the Client. It allows sending the metrics less often which can be useful for performance intensive code paths.
  sample_rate: 1
  # Tags appends the given tags to the tags sent with every metrics. If a tag already exists, it is replaced.
  tags: {a: b}

sentry:
  dsn: "http://user@127.0.0.1/1"
  # 以下配置皆为可选
  
  # sentry捕获到panic后,是否再标记为panic,以使rock的PanicHandler可以捕获,如关闭则rock.SetPanicHandler无效
  repanic: true
  # In debug mode, the debug information is printed to stdout to help you understand what sentry is doing.
  debug: false
  # 采样率,0.0~1.0,默认为1
  sample_rate: 1
  # 以正则表达式列表表示的可忽略的错误
  ignore_errors: []
  server_name: mydomain.com
  release: "Release name to report"
  dist: "The dist to be sent with events"
  environment: "The environment to be sent with events"
  max_breadcrumbs: 9 # Maximum number of breadcrumbs
  timeout_seconds: 10 # 请求超时的秒数

Clone this wiki locally