Skip to content

When using otel, the logc print log will be deformed #5133

@Cairry

Description

@Cairry

Describe the bug
My service uses otel. When printing logs through logc, the log format is deformed. I understand that traceid and spanid should be inside json, not in the outer layer.

  1. The code is

    logc.Infow(context.Background(), "CallBack request successfully.", logc.Field("reqId", params.Spec.ReqId))
  2. The error is

    trace_id=dfac27371ea9966e8da25340b5924dc7 span_id=6fe11f97dfa23e52{"@timestamp":"2025-08-26T13:49:09.815+08:00","caller":"task/task.go:88","content":"CallBack request successfully.","level":"info","reqId":"1960191682599202817","span":"6fe11f97dfa23e52","trace":"dfac27371ea9966e8da25340b5924dc7"}
    

Expected behavior

{"@timestamp":"2025-08-26T13:49:09.815+08:00","caller":"task/task.go:88","content":"CallBack request successfully.","level":"info","reqId":"1960191682599202817","span":"6fe11f97dfa23e52","trace":"dfac27371ea9966e8da25340b5924dc7"}

Environments (please complete the following information):

  • OS: Ubuntu
  • go-zero version:v1.7.3
  • goctl version:1.23.0

More description
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions