콘텐츠로 이동

로그 설정

var c logc.LogConf
logc.Must설정(c)
logc.Info(context.Background(), "log")
// do your job

Our 로그 is 참조d 통해 serviceConf과 will be 자동으로 initialized 때 service은 started입니다.

LogConf 설정 definition below:

package logx
// A, LogConf 예시입니다
type LogConf struct {
ServiceName string `json:",optional"`
Mode string `json:",default=console,options=[console,file,volume]"`
Encoding string `json:",default=json,options=[json,plain]"`
TimeFormat string `json:",optional"`
Path string `json:",default=logs"`
Level string `json:",default=info,options=[debug,info,error,severe]"`
MaxContentLength uint32 `json:",optional"`
Compress bool `json:",optional"`
Stat bool `json:",default=true"` // go-zero 版本 >= 1.5.0 才支持
KeepDays int `json:",optional"`
StackCooldownMillis int `json:",default=100"`
// MaxBackups 예시입니다
// size, Only, RotationRuleType 예시입니다
// MaxBackups, Even 예시입니다
// KeepDays 예시입니다
MaxBackups int `json:",default=0"`
// MB, MaxSize 예시입니다
// size, Only, RotationRuleType 예시입니다
MaxSize int `json:",default=0"`
// daily, RotationRuleType, Default 예시입니다
// 예시입니다
// 예시입니다
Rotation string `json:",default=daily,options=[daily,size]"`
}
ParamsDataType기본값 value참고Enum Values
ServiceNamestringService Name
Modestringconsole로그 Printing Mode, console Console파일, console
Encodingstringjson이 항목은 해당 기능의 사용 방법, 설정, 주의 사항을 설명합니다.json, plain
TimeFormatstringDate Format
경로string로그로그 출력 경로 에서 파일 출력 mode
Levelstringinfo로그 출력 leveldebug,info,오류,severe
MaxContentLengthuint320이 항목은 해당 기능의 사용 방법, 설정, 주의 사항을 설명합니다.
CompressboolfalseWhether 로 compress 로그
StatbooltrueWhether 로 비활성화 stat 로그, go-zero 버전 is greater than 1.5.0
KeepDaysint0로그 number 의 days left, 만 에서 파일 mode
StackCooldownMillisint100Stack print cooldown time
MaxBackupsint0이 항목은 해당 기능의 사용 방법, 설정, 주의 사항을 설명합니다.
MaxSizeint0파일 출력 mode, single 파일 크기 때 split 통해 크기
Rotationstringdaily파일 split mode, daily 통해 datedaily,크기