#5133·go-zero

When using otel, the logc print log will be deformed

Author: CairryCreated Aug 29, 2025Updated Sep 5, 2026
Labelsstale

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

    go
    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.