Serilog writers for Profiler (https://github.com/r-alekseev/Profiler)
Profiler is minimalistic and fast profiling library for .NET
Serilog is simple .NET logging project with fully-structured events
This project contains components and configurations that provide the ability to write profiling traces and reports to structured events in Serilog.
Configuration basics: https://github.com/serilog/serilog/wiki/Configuration-Basics
Provided sinks: https://github.com/serilog/serilog/wiki/Provided-Sinks
Just an example of configuring a logger to a JSON text file and to the console.
var logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.File(new CompactJsonFormatter(), "log.txt")
.WriteTo.Console()
.CreateLogger();
Just another example of configuring a logger to the Elasticsearch index.
var logger = new LoggerConfiguration()
.Enrich.WithExceptionDetails()
.WriteTo.Elasticsearch(
nodeUris: "http://some-address:9200",
indexFormat: "some-service-{0:yyyy.MM.dd}",
autoRegisterTemplate: true)
.CreateLogger();
Call UseSerilogTraceWriter
method for set up writing trace to Serilog.
Pass an instance of the logger configured above to UseLogger
method.
var profiler = new ProfilerConfiguration()
.UseSerilogTraceWriter(settings => settings
.UseLogEventLevel(LogEventLevel.Verbose)
.UseLogger(logger))
.CreateProfiler();
Call UseSerilogReportWriter
method for set up writing metrics report to Serilog.
Pass an instance of the logger configured above to UseLogger
method.
var profiler = new ProfilerConfiguration()
.UseSerilogReportWriter(settings => settings
.UseLogEventLevel(LogEventLevel.Information)
.UseLogger(logger))
.CreateProfiler();