|
|
@@ -8,9 +8,9 @@ import (
|
|
8
|
8
|
// LogConfig 日志配置
|
|
9
|
9
|
type LogConfig struct {
|
|
10
|
10
|
BaseConfig
|
|
11
|
|
- Level string `yaml:"level" json:"level"` // 日志级别
|
|
12
|
|
- Output string `yaml:"output" json:"output"` // 输出目标:console,file,es
|
|
13
|
|
- JSONFormat bool `yaml:"json_format" json:"json_format"` // 是否JSON格式
|
|
|
11
|
+ Level string `yaml:"level" json:"level"` // 日志级别
|
|
|
12
|
+ Output string `yaml:"output" json:"output"` // 输出目标:console,file,es
|
|
|
13
|
+ //JSONFormat bool `yaml:"json_format" json:"json_format"` // 是否JSON格式
|
|
14
|
14
|
|
|
15
|
15
|
// 文件输出配置
|
|
16
|
16
|
FilePath string `yaml:"file_path" json:"file_path"`
|
|
|
@@ -20,12 +20,12 @@ type LogConfig struct {
|
|
20
|
20
|
Compress bool `yaml:"compress" json:"compress"`
|
|
21
|
21
|
|
|
22
|
22
|
// ES输出配置(当Output包含"es"时生效)
|
|
23
|
|
- ESPath string `yaml:"es_path" json:"es_path"` // ES地址
|
|
24
|
|
- ESUsername string `yaml:"es_username" json:"es_username"` // 用户名(可选)
|
|
25
|
|
- ESPassword string `yaml:"es_password" json:"es_password"` // 密码(可选)
|
|
26
|
|
- ESAPIKey string `yaml:"es_api_key" json:"es_api_key"` // API Key(可选)
|
|
27
|
|
- ESBuffer int `yaml:"es_buffer" json:"es_buffer"` // 缓冲大小,默认10000
|
|
28
|
|
- ESMaxRetry int `yaml:"es_max_retry" json:"es_max_retry"` // 最大重试,默认3
|
|
|
23
|
+ ESPath string `yaml:"es_path" json:"es_path"` // ES地址
|
|
|
24
|
+ ESUsername string `yaml:"es_username" json:"es_username"` // 用户名(可选)
|
|
|
25
|
+ ESPassword string `yaml:"es_password" json:"es_password"` // 密码(可选)
|
|
|
26
|
+ //ESAPIKey string `yaml:"es_api_key" json:"es_api_key"` // API Key(可选)
|
|
|
27
|
+ //ESBuffer int `yaml:"es_buffer" json:"es_buffer"` // 缓冲大小,默认10000
|
|
|
28
|
+ //ESMaxRetry int `yaml:"es_max_retry" json:"es_max_retry"` // 最大重试,默认3
|
|
29
|
29
|
}
|
|
30
|
30
|
|
|
31
|
31
|
// NewLogConfig 创建日志配置实例
|
|
|
@@ -43,7 +43,7 @@ func (c *LogConfig) SetDefaults() {
|
|
43
|
43
|
c.MaxAge = 30
|
|
44
|
44
|
c.Compress = true
|
|
45
|
45
|
c.ESPath = "logs/es-service.log"
|
|
46
|
|
- c.JSONFormat = true
|
|
|
46
|
+ //c.JSONFormat = true
|
|
47
|
47
|
}
|
|
48
|
48
|
|
|
49
|
49
|
// Load 从yaml数据加载
|