Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何更改日志格式 #86

Closed
DynamicLoader opened this issue Apr 16, 2021 · 1 comment
Closed

如何更改日志格式 #86

DynamicLoader opened this issue Apr 16, 2021 · 1 comment

Comments

@DynamicLoader
Copy link

当前的日志格式如下(时间_级别_代码_信息):

2021-04-16T16:31:49.266+0800 INFO server/server.go:1097 init plugin hook wrappers
2021-04-16T16:31:49.266+0800 INFO server/server.go:880 open persistence succeeded {"type": "memory"}

我想更改它的格式,确保它与我的代码所使用的日志格式相同,例如 级别_时间_信息,但是没有在文档中找到定义字段的方法。

万望不吝赐教。谢谢。

@DrmagicE
Copy link
Owner

不支持通过配置的方式更改日志格式,gmqtt使用zap做日志库。具体如何更改格式要看如何对zap做配置了。
gmqtt初始化日志的方法:

func (c Config) GetLogger(config LogConfig) (l *zap.Logger, err error) {

如果要对日志格式做定制化,可能要改一下源码了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants