deck-chores
deck-chores copied to clipboard
Logs in other formats
Is it possible to logging in JSON format (like GELF format)? To have a more meaningful structured data in tools like Seq, Graylog, Logstash, Fluentd...
well, i'd like to consider deck-chores
as feature-complete. but i'm not completely against adding features, it just depends on the concrete proposal. regarding your request:
- it must be clarified whether GELF or a custom JSON-based format shall be emitted
- someone must provide a full design proposal that needs to be agreed upon
- someone must implement the feature eventually in a maintainable manner
I recently started using docker and centralized log collection systems. I do not have considerable expertise, but there are some observations.
In practice I noticed that for example Traefik has a switch for log format (common/json) .
I use Seq to collect logs from Docker containers. In correspondence with support they told me that Seq supports Compact Log Event Format (CLEF): https://clef-json.org/.
As far as I understand, the application itself doesn't need to support GELF or other ways to send logs to the collectors (transport layer).
The application only needs to encode its messages as a JSON string with some predefined keys (importance level, message header).
For example, in PHP I can easily generate an array of any nested information I want. And then I add two additional predefined fields (according to the CLEF specification):
@l - the importance level
@m - a generalized text message
Then I just encode the array before outputting it to JSON.
In the log collector interface the messages received in JSON format are automatically converted into structured data with the possibility of expansion, filtering, alerts, etc.
There is also python-json-logger.
okay, given that there are many log formats of interest now and in the future, the only feasible way is a plugin-based approach.
if anyone is seriously interested to implement this, let me know so i can provide general pointers for the endeavor.