Skip to content

Serilog sinks that write events to Object-Centric Event Logs (OCEL)

License

Notifications You must be signed in to change notification settings

pm4net/serilog-sinks-ocel

Repository files navigation

Serilog.Sinks.OCEL

GitHub GitHub Workflow Status Nuget (with prereleases) Nuget

Serilog sinks that write events to Object-Centric Event Logs (OCEL) [1], using the .NET OCEL library.

There is a separate sinks for each of the supported OCEL format: Serilog.Sinks.OCEL.Sinks.OcelJsonSink, Serilog.Sinks.OCEL.Sinks.OcelXmlSink, and Serilog.Sinks.OCEL.Sinks.OcelLiteDbSink.

Rolling files are supported by configuring the log directory and file name separately. Depending on the rolling period, the file name is prepended with an identifier.

Sample configuration:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Information()
    .WriteTo.OcelLiteDbSink(new LiteDbSinkOptions(string.Empty, "log.db", RollingPeriod.Never))
    .CreateLogger();

Or via appsettings.json (using Serilog.Settings.Configuration):

"Serilog": {
    "MinimumLevel": {
      "Default": "Information"
    },
    "WriteTo": [
      {
        "Name": "Console"
      },
      {
        "Name": "OcelJsonSink",
        "Args": {
          "directory": "",
          "fileName": "log.jsonocel",
          "rollingPeriod": "Month",
          "formatting": "Indented",
          "prefix": "myprefix_"
        }
      }
    ]
  }

Supported formats

The OCEL standard is defined for both JSON and XML. Both include a validation schema that is used by the library to validate input.

An additional useful format is to store OCEL data in document databases such as MongoDB [2]. A very good alternative for .NET is LiteDB, which is an embedded NoSQL database that is similar to MongoDB. It allows writing to files directly and does not require a database server to use. Support for MongoDB will be evaluated in the future.

Format Status
JSON Implemented
XML Implemented
LiteDB Implemented
MongoDB TBD

Performance

JSON and XML files cannot simply be appended like a text file or a database table. The entire file has to be rewritten each time, which is expensive. If you are going to use either the JSON or XML sink, make sure to use short rolling periods to avoid log files with more than a few thousand events at a time. It is generally recommended to use the LiteDb sink for all logging due to better performance, even though LiteDb files tend to be larger in size overall. The OCEL library can be used to later convert between formats or even merge multiple files together.

References

[1] Farhang, A., Park, G. G., Berti, A., & Aalst, W. Van Der. (2020). OCEL Standard. http://ocel-standard.org/

[2] Berti, A., Ghahfarokhi, A. F., Park, G., & van der Aalst, W. M. P. (2021). A Scalable Database for the Storage of Object-Centric Event Logs. CEUR Workshop Proceedings, 3098, 19–20. https://arxiv.org/abs/2202.05639.

About

Serilog sinks that write events to Object-Centric Event Logs (OCEL)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages