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 · 0 comments
Open

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

Chen-Guorui opened this issue Dec 6, 2024 · 0 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
}
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

1 participant