Re:Ask HN: How do you log application events?
by mdaniel on Monday April 27, 2015 @03:30PM
(#9448593)
When I've heard "structured logging" used, it has been in the context of much more key-value pairs than just having keywords next to values, e.g.
Log.Info("customerNum={customerNumber} transactionId={transactionId} state=completed", cN, tID)
or the ever popular logstash-y format: Log.Info(LogState.Add("state", "completed").Add("customerId", customerId).Add("transactionId", transactionId));
where `LogState` would build up a key-value dict and its `ToString` would emit the logstash JSON format.I guess the version that works best depends on the tool that is consuming the log text.
Log.Info("Customer# {customerNumber} completed transaction {transactionId}", customerNumber, transactionId);
Then using the Seq log viewer you can simply click on "transactionId" in the log line and filter by "transactionId = 456" or whatever. It's one of the most exciting advancements I've seen in the .Net logging world.
EDIT: I realized I didn't really answer OPs question regarding space. If you used Serilog, you can set up different sinks to export to, with different options. For example, you could send all your logs to mongodb, and just recent 1 week rolling logs to the Seq server.