-
Notifications
You must be signed in to change notification settings - Fork 17
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
how to use zap.field? #32
Comments
Not supported, complex log printing is recommended using the native zap |
However, it is recommended that hlog be injected into the zap implementation as well to ensure that both framework logs and business logs can be seen. |
what about |
not support and i recommend using zap directly, you can use hlog.SetLogger to inject zap and ensure that the framework logs are collected by you as well. |
@wuyunhua1987 现在 zap 支持导出原生 logger, 以支持复杂操作 logger := hertzap.NewLogger()
hlog.SetLogger(logger)
h.GET("/hello", func(ctx context.Context, c *app.RequestContext) {
logger.Logger().Info("Hello, World!", zap.Int("status", c.Response().StatusCode()))
c.String(consts.StatusOK, "Hello hertz!")
}) |
eg: zap.String("name", "john"), zap.Int("age", 18), then json output likes this: {"name": "john", "age": 18}
The text was updated successfully, but these errors were encountered: