Browse Source

修改日志模块读取配置文件的位置和文件名

pull/210/head
zhangxin 3 years ago
parent
commit
6c15792c54
3 changed files with 71 additions and 2 deletions
  1. +0
    -0
      conf/log_config.yaml
  2. +2
    -2
      infra/logger/config.go
  3. +69
    -0
      infra/logger/log_config.yaml

infra/logger/config.yaml → conf/log_config.yaml View File


+ 2
- 2
infra/logger/config.go View File

@ -48,9 +48,9 @@ type outputSettings struct {
func InitConfig() error {
var err error
viper.SetConfigName("config")
viper.SetConfigName("log_config")
viper.SetConfigType("yaml")
viper.AddConfigPath("./")
viper.AddConfigPath("./conf/")
if err = viper.ReadInConfig(); err != nil {
return err
}


+ 69
- 0
infra/logger/log_config.yaml View File

@ -0,0 +1,69 @@
# 配置输出 支持三种输出 db file 和console
# db为数据库输出 目前支持输出到mongo 配置为map
db:
mongo1:
dbtype: mongo
host: 127.0.0.1
port: 27017
database: GAAS_MOM
# mongo的collection
Table: LOG
mongo2:
dbtype: mongo
host: 127.0.0.1
port: 27017
database: GAAS_MOM
# mongo的collection
Table: LOG2
# file为输出到文件 配置为map 按天分割
file:
common:
# 文件location
filename: ./log/common.log
# 支持文件的最大个数
MaxAge: 30
user:
# 文件location
filename: ./log/user.log
# 支持文件的最大个数
MaxAge: 7
# console 为输出到控制台
console:
enable: true # bool 是否输出到控制台
# module配置输出源 配置为map
config:
# root为根配置 默认配置 module未配置则使用root配置
root:
# 此处的file、db、console名称可以随意起 见文知意即可
file:
# drivertype 为驱动类型 file-文件 db-数据库 console-控制台
drivertype: file
level: debug
# drivername 需要和output的map 键值相同
drivername: common
db:
drivertype: db
level: debug
drivername: mongo1
console:
drivertype: console
level: debug
drivername: console
user:
file:
# drivertype 为驱动类型 file-文件 db-数据库 console-控制台
drivertype: file
level: info
# drivername 需要和output的map 键值相同
drivername: user
db:
drivertype: db
level: debug
drivername: mongo2

Loading…
Cancel
Save