Comments (8)
logrus可以简单看下这里。
https://gist.github.com/rogerogers/175d5e8bd451992175e553de9dc8a615
zap就比较简单了。
package main
import (
"context"
"github.com/cloudwego/hertz/pkg/common/hlog"
hertzzap "github.com/hertz-contrib/logger/zap"
"go.uber.org/zap"
)
func main() {
logger := hertzzap.NewLogger(hertzzap.WithZapOptions(zap.WithCaller(true), zap.AddCallerSkip(2)))
hlog.SetLogger(logger)
hlog.CtxInfof(context.Background(), "hello %s", "hertz")
}
from obs-opentelemetry.
有解决方案吗? 用 kitex 微服务开发 打印日志后,如果没有对应的文件和 行号,定位代码位置的效率比较低
from obs-opentelemetry.
可以参考下这个,is-it-possible-to-wrap-logrus-logger-functions-without-losing-the-line-number-pr,另外zap的话有自带zap.AddCallerSkip
方法。
有解决方案吗? 用 kitex 微服务开发 打印日志后,如果没有对应的文件和 行号,定位代码位置的效率比较低
from obs-opentelemetry.
可以参考下这个,is-it-possible-to-wrap-logrus-logger-functions-without-losing-the-line-number-pr,另外zap的话有自带
zap.AddCallerSkip
方法。有解决方案吗? 用 kitex 微服务开发 打印日志后,如果没有对应的文件和 行号,定位代码位置的效率比较低
有使用示例吗?
from obs-opentelemetry.
示例我用的hertz,kitex代码差不多的。
from obs-opentelemetry.
logrus可以简单看下这里。 gist.github.com/rogerogers/175d5e8bd451992175e553de9dc8a615
zap就比较简单了。
package main import ( "context" "github.com/cloudwego/hertz/pkg/common/hlog" hertzzap "github.com/hertz-contrib/logger/zap" "go.uber.org/zap" ) func main() { logger := hertzzap.NewLogger(hertzzap.WithZapOptions(zap.WithCaller(true), zap.AddCallerSkip(2))) hlog.SetLogger(logger) hlog.CtxInfof(context.Background(), "hello %s", "hertz") }
已解决
from obs-opentelemetry.
这个讲的啥?要的是日志打印的来源文件,这说的啥????
from obs-opentelemetry.
这个讲的啥?要的是日志打印的来源文件,这说的啥????
解决方案就是调整runtime信息来输出日志打印位置,有什么疑问可以具体描述下?
from obs-opentelemetry.
Related Issues (10)
- kitex启用链路追踪时报错 HOT 6
- 这个项目和社区另一个项目monitor-prometheus都能导出kitex的一些metric?应该如何选择? HOT 3
- import github.com/kitex-contrib/obs-opentelemetry/provider error HOT 2
- 我想在使用zap的实例,hlog.CtxDebugf(ctx,"test")默认打印ctx里的logid,我可以在hlog哪里注入呢 HOT 2
- 我想在上游go服务通过kitex client请求kitex服务的把trace_id 的信息传到下游服务,我应该通过哪个函数可以设置传下去的trace信息呢 HOT 3
- span状态设置问题 HOT 2
- slog的支持计划有吗 HOT 1
- recordStackTraceInSpan param do not use HOT 2
- Proposal: need method to specific tracerProvider and Sampler HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obs-opentelemetry.