Is your feature request related to a problem?
Option Yes
Describe the solution you'd like
使用 json 格式输出时
logger := g.Log()
logger.SetHandlers(glog.HandlerJson)
logger.SetCtxKeys("Trace-Id", "Client-IP")
ctx := context.WithValue(context.Background(), "Trace-Id", "123456789")
ctx = context.WithValue(ctx, "Client-IP", "1.2.3.4")
logger.Debug(ctx, g.Map{"uid": 100, "name": "john"})
当前输出为
{
"Time": "2026-07-02T09:06:53.477+08:00",
"CtxStr": "123456789, 1.2.3.4",
"Level": "DEBU",
"Content": "{\"name\":\"john\",\"uid\":100}"
}
无法直接导入 ES、LTS 等日志分析工具,下面纯 json 的格式才可以
{
"Time": "2026-07-02T09:06:53.477+08:00",
"Trace-Id": "123456789",
"Client-IP": "192.168.2.3",
"Level": "DEBU",
"name": "john",
"uid": 100
}
注:以上仅为展示结构,真正输出必须为单行的 jsonl
Describe alternatives you've considered
在 filebeat 中添加复杂的规则转换
Additional
No response
Is your feature request related to a problem?
Option Yes
Describe the solution you'd like
使用 json 格式输出时
当前输出为
{ "Time": "2026-07-02T09:06:53.477+08:00", "CtxStr": "123456789, 1.2.3.4", "Level": "DEBU", "Content": "{\"name\":\"john\",\"uid\":100}" }无法直接导入 ES、LTS 等日志分析工具,下面纯 json 的格式才可以
{ "Time": "2026-07-02T09:06:53.477+08:00", "Trace-Id": "123456789", "Client-IP": "192.168.2.3", "Level": "DEBU", "name": "john", "uid": 100 }注:以上仅为展示结构,真正输出必须为单行的 jsonl
Describe alternatives you've considered
在 filebeat 中添加复杂的规则转换
Additional
No response