3 ms·
logging And for the love of all that is holy don’t just log to a text file. Use some type of structured logging framework (Serilog,StructLog,etc.) that gives y
by scarface74 8y ago
logging
And for the love of all that is holy don’t just log to a text file. Use some type of structured logging framework (Serilog,StructLog,etc.) that gives you JSON structured logging that you can then query instead of depending on regular expressions.
- majewsky 8y agoWhy though? Even if your own app logs JSON, everything around it (the DB, the log collector, the metrics collector, the kernel, the LDAP server) most likely logs plain text, so you need to know regexes anyway.
- scarface74 8y agoOh that’s the other part. With the structured logging framework that I’m most familiar with - Serilog - if you send it to an output source like Mongo or ElasticSearch it logs documents. So you can query your logs. With Serilog you can tell it to always add certain attributes and you can tell it to add attributes with a certain context - like everything in a “using” block. As far as the logs that you don’t control, if they are in some sort of standardized format even if it is just a line of text, you can use logstash to create a structure around it. Of course with ElasticSearch, you have a powerful reporting app in Kibana. If you are on AWS you can send logs to CloudWatch and use the alerting, metric framework that’s built in.