Serilog adapter for WorkflowForge providing professional structured logging capabilities with rich context and correlation.
$ dotnet add package WorkflowForge.Extensions.Logging.SerilogStructured logging extension for WorkflowForge with Serilog integration for rich, queryable logs.
This extension internalizes Serilog with ILRepack. This means:
dotnet add package WorkflowForge.Extensions.Logging.Serilog
Requires: .NET Standard 2.0 or later
using WorkflowForge.Extensions.Logging.Serilog;
var logger = SerilogLoggerFactory.CreateLogger(new SerilogLoggerOptions
{
MinimumLevel = "Information",
EnableConsoleSink = true
});
using var foundry = WorkflowForge.CreateFoundry("MyWorkflow", logger);
var logger = SerilogLoggerFactory.CreateLogger(new SerilogLoggerOptions
{
MinimumLevel = "Information",
EnableConsoleSink = true
});
using var foundry = WorkflowForge.CreateFoundry("MyWorkflow", logger);
{
"Serilog": {
"MinimumLevel": "Information",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "logs/workflow-.txt",
"rollingInterval": "Day"
}
}
]
}
}
See Configuration Guide for complete options.
foundry.Logger.LogInformation(
"Processing order {OrderId} for customer {CustomerId}",
orderId,
customerId);
using (LogContext.PushProperty("WorkflowId", workflow.Id))
{
foundry.Logger.LogInformation("Workflow started");
// All logs in this scope include WorkflowId
}
var sw = Stopwatch.StartNew();
// ... operation ...
sw.Stop();
foundry.Logger.LogInformation(
"Operation {OperationName} completed in {Duration}ms",
operation.Name,
sw.Elapsed.TotalMilliseconds);
.WriteTo.Console(outputTemplate:
"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
.WriteTo.File(
"logs/workflow-.txt",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 7)
.WriteTo.Seq("http://localhost:5341")
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9200")))