You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/22 07:14:51 UTC

[GitHub] [dubbo-go] Mulavar opened a new issue #1477: 关于统一日志规范的建议讨论与收集

Mulavar opened a new issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477


   <!-- Please only use this template for submitting enhancement requests -->
   
   **What would you like to be added**:
   对现有 dubbo-go 的日志进行统一梳理,主要工作包含两部分:
   1. 日志内容格式统一,要简短并包含足够的有效信息;
   2. 日志级别统一,明确哪类日志用哪种规范。
   欢迎大家继续补充。
   **Why is this needed**:
   现有的 dubbo-go 日志混乱,启动时有大量用户不关心的日志信息输出,影响实际体验,且一些日志冗余无效,对定位问题毫无帮助。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei edited a comment on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei edited a comment on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-966016947


   而且我觉得还有一条是:如果 error 被返回,则不需要框架打印,由用户自行决定打印方式。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-966015139


   > 拼接错误信息时不要使用 fmt.Sprintf,会造成逃逸,引起 GC
   
   正确姿势是什么?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-966015562


   > 设置日志默认级别设置为 Info
   
   那在 dubbo-go-samples 中是不是需要显式使用 debug 级别?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-966016947


   而且我觉得还有一条是:如果 error 被返回,则不需要框架打印


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] XiaoWeiKIN commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
XiaoWeiKIN commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-926421285


   1. 建议只有关键流程的日志增加info级别日志,非关键性日志使用debug或者不打印。
   2. 打印日志要注意需要有具体含义,没有具体含义的日志不要打印。
   3. 对于调用流程中的日志打印要格外注意,应当使用debug级别。避免用户在使用过程中产出过多无用日志。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-932888553


   尽量封装好 log 的格式,并且使用 error wrapper 的方式封装错误,log 格式比如: `fmt.Errorf("[%s] %s, %s, %s: \n%w", "函数名称", "brief msg", "key1", "value1", err)`。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei edited a comment on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei edited a comment on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-932888553


   尽量封装好 log 的格式,并且使用 error wrapper 的方式封装错误,log 格式比如: `fmt.Errorf("[%s] %s, %s, %s: \n%w", "函数名称", "brief msg", "key1", "value1", err)`。
   
   这样的好处是可以使用 `errors.Is()` 判断错误的类型。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] Mulavar commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
Mulavar commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-924661313


   【日志级别】
   建议目前删除一些非关键日志或将其日志调整为 DEBUG,默认级别为 INFO。
   1. 非关键流程:如 filter 的出入口,注册中心上注册的具体数据内容,元数据中心的元数据具体内容,一些通信建立相关的日志;
   2. 关键流程:如服务发布成功后的流程。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] zhaoyunxing92 commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
zhaoyunxing92 commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-924656797


   1.目前日志固定的是zap,希望可以支持配置其他日志框架
   2.启动的时候日志模块加载完成后应该同步设置好getty、nacos等等sdk的日志,当然可以sdk自定义


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei edited a comment on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
justxuewei edited a comment on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-932888553


   尽量封装好 log 的格式,并且使用 error wrapper 的方式封装错误,log 格式比如:`fmt.Errorf("[%s] %s, %s, %s: \n%w", "函数名称", "brief msg", "key1", "value1", err)`。
   
   这样的好处是可以使用 `errors.Is()` 判断错误的类型。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] Mulavar commented on issue #1477: 关于统一日志规范的建议讨论与收集

Posted by GitBox <gi...@apache.org>.
Mulavar commented on issue #1477:
URL: https://github.com/apache/dubbo-go/issues/1477#issuecomment-965556745


   Dubbo-go 现存日志问题:
   1. 无法清除掌握系统的运行状态;
   2. 系统出现问题较难快速定位。
   
   
   1. 明确日志级别
   - Debug:面向开发者,主要集中在具体参数的打印,方便调试追踪错误,如系统读入的配置数据、底层通信协议发送/接收请求时序列化/反序列化的一些行为,但那些在开发过程中为了调试方便而加入的临时日志应该删除。
   - Info:面向所有人,需要在关键流程处打印,如配置中心启动、元数据中心启动、注册中心启动、服务发布成功或监听的服务元数据发生变更等。
   - Warn:面向所有人,预期会发生且能够被正常处理的异常,且不影响 dubbo-go 正常运行。
   - Error:面向所有人,无法被正常处理的异常,会影响到正常运行,如注册中心启动失败、服务暴露失败等。
   
   TODO
   -   设置日志默认级别设置为 Info
   -   统一日志内容格式:[Func] [Description], [Message]. [Params]
       -   Func:具体函数名或操作名,要求能快速定位到报错位置。
       -   Description:大写字母开头,如果是 Error 日志则为错误描述信息,简要描述发生了什么错误;如果是 Warn 日志则
       -   Message:大写字母开头,错误的可能原因(Maybe),以及可能有效的解决(Probably need to do)方式。
       -   Params:与该次错误相关的参数列表。
   对 Info 日志和 Debug 日志来说,Description 和 Message 可以认为是等价的,只填其中一个即可,因此 Info、Debug 日志的的格式又可以为:[Func] [Message]. [Params]。
   
   注意事项
   1.  拼接错误信息时不要使用 fmt.Sprintf,会造成逃逸,引起 GC。
   2.  关于 error 的传递,尽量不要使用 errors.New,推荐提前定义好 error 常量,并以 wrapper 的形式包装返回给上层,这样上层能通过 errors.Is 进行类型判断。
   
   
   参考
   https://zhuanlan.zhihu.com/p/27363484
   https://github.com/alibaba/sentinel-golang/pull/293


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org