Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.14k stars 80 forks source link

Binary logging support? #43

Closed zejji closed 3 years ago

zejji commented 3 years ago

I'm investigating ZLogger in the context of wanting to log every event that occurs within a system to a flat file.

Specifically, I am aiming to use a simple CQRS mechanism which logs every event to a file. The aim is to achieve the auditability benefits of event sourcing, but without the additional cost of maintenance (and hardware) required for a full event sourcing solution. For the app's data layer, I am currently happy with a standard PostgreSQL database for both reads and writes, but would like to have a record of everything that happens in the system. Obviously event logging performance would be very important for this use case. Ideally the logs could also be used to reconstruct state at a later date (via projections) if required.

Do you have any plans to implement a binary log file format and, if not, do you have any suggestions as to how to best go about this?

I was thinking about using typeless MessagePack, but ideally one needs to know how to reliably version the serialized types if reconstruction is required. One option might be to include a hash of type definition somehow? Another option might be to include the type schemas in the header of each log file (or in a separate schema file). I'd be grateful for any thoughts or suggestions.

neuecc commented 3 years ago

interesting suggestion. However, currently tightly coupled with System.Text.Json so difficult to adapt messagepack.