我正在阅读GELF规范,因为我正在将其集成到我们的系统中。 我只是想知道是否一个额外的/自定义字段可以包含一个JSON对象,因为规范没有提到它:
所以我的GELF输出(特别是下面的_request字段)看起来像这样:
{ "version": "1.0", "host": "www1", "short_message": "Short message", "full_message": "Backtrace here\n\nmore stuff", "timestamp": 1291899928, "level": 1, "facility": "payment-backend", "file": "/var/www/somefile.rb", "line": 356, "_request": { "ip": "123.123.123.123", "url": "example.com/dir/file.ext", "method": "get", "referer" "example.net" }
目前GELF不支持嵌套的JSON对象,但如果有人有兴趣请在groups.google.com/forum/#!topic/graylog2/Xg3v3Qh8fmo评论。
我认为避免这种嵌套结构会更好,这会使事情变得复杂。 你可以将其平坦化,并将其放入JSON中:
_request_ip _request_url _request_method _request_referer