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

How can I send logs printed by myself to Jaeger? #4483

Open
Chen-Guorui opened this issue Dec 6, 2024 · 2 comments
Open

How can I send logs printed by myself to Jaeger? #4483

Chen-Guorui opened this issue Dec 6, 2024 · 2 comments

Comments

@Chen-Guorui
Copy link

Chen-Guorui commented Dec 6, 2024

默认开启TraceHandler后,每条http请求都会有日志发送到Jaeger,但是我自己打印的日志并不会被发送,我想问是否有一些配置可以实现,我查阅了文档后没发现相关方法。

package logic

import (
	"context"
	"trace/internal/svc"
	"trace/internal/types"
	"github.com/zeromicro/go-zero/core/logx"
)

type TraceLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewTraceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TraceLogic {
	return &TraceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *TraceLogic) Trace(req *types.Request) (resp *types.Response, err error) {
	resp = &types.Response{
		Message: "Hello " + req.Name,
	}
 
        // 我想把这条日志也一并发送到Jaeger
	l.Logger.Info("Hello")
	return
}
@kslamph
Copy link

kslamph commented Jan 27, 2025

http请求后被发送给jeager的是otl tracing数据并非log. logx清晰的支持两个模式console和file,要想把log传到分布式的log digester比如elasticsearch或loki等,一般就是两个方法通过比如promtail类似等服务把文件传送过去,或者集成其他logwriter,gozero支持zap和logrus

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After the http request, the OTL Tracing data is not sent to Jeager. Similar services of PromTail transmit files, or integrate other logwriters, Gozero support ZAP and Logrus

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

3 participants