You can do this by first making sure that the performance counter events are marked with either a specific property value ( OpenMappedContext() in LibLog) or from a specific type / namespace.
var log = LogProvider.For<MyApp.Performance.SomeCounter>() log.Info(...);
When configuring Serilog, a sub-logger with a filter applied can send only the necessary events to the second file.
Log.Logger = new LoggerConfiguration() .WriteTo.Logger(lc => lc .Filter.ByExcluding(Matching.FromSource("MyApp.Performance")) .WriteTo.File("first.json", new JsonFormatter())) .WriteTo.Logger(lc => lc .Filter.ByIncludingOnly(Matching.FromSource("MyApp.Performance")) .WriteTo.File("second.json", new JsonFormatter())) .CreateLogger();
Nicholas blumhardt
source share