Akka.Logger.Serilog 1.5.25
Akka.Logger.Serilog
This is the Serilog integration plugin for Akka.NET. Please check out our documentation on how to get the most out of this plugin.
Targets Serilog 2.12.0.
Semantic Logging Syntax
If you intend on using any of the Serilog semantic logging formats in your logging strings, you need to use the SerilogLoggingAdapter inside your instrumented code or there could be elsewhere inside parts of your ActorSystem
:
var log = Context.GetLogger<SerilogLoggingAdapter>(); // correct
log.Info("My boss makes me use {semantic} logging", "semantic"); // serilog semantic logging format
or
var log = MyActorSystem.GetLogger<SerilogLoggingAdapter>(myContextObject); // correct
log.Info("My boss makes me use {semantic} logging", "semantic"); // serilog semantic logging format
or
var log = MyActorSystem.GetLogger<SerilogLoggingAdapter>(contextName, contextType); // correct
log.Info("My boss makes me use {semantic} logging", "semantic"); // serilog semantic logging format
This will allow all logging events to be consumed anywhere inside the ActorSystem
, including places like the Akka.NET TestKit, without throwing FormatException
s when they encounter semantic logging syntax outside of the SerilogLogger
.
Adding Property Enricher To Your Logs
Default Properties
You can add property enrichers to the logging adapter that will be added to all logging calls to that logging adapter.
var log = Context.GetLogger<SerilogLoggingAdapter>()
.ForContext("Address", "No. 4 Privet Drive")
.ForContext("Town", "Little Whinging")
.ForContext("County", "Surrey")
.ForContext("Country", "England");
log.Info("My boss makes me use {Semantic} logging", "semantic");
All logging done using the log
ILoggingAdapter
instance will append "Address", "Town", "County", and "Country" properties into the Serilog log.
One-off Properties
You can add one-off property to a single log message by appending PropertyEnricher
instances at the end of your logging calls.
var log = Context.GetLogger<SerilogLoggingAdapter>();
log.Info(
"My boss makes me use {Semantic} logging", "semantic",
new PropertyEnricher("County", "Surrey"),
new PropertyEnricher("Country", "England"));
This log entry will have "County" and "Country" properties added to it.
Automatically Convert ILoggingAdapter
into SerilogLoggingAdapter
As of Akka.Logger.Serilog v1.5.25, you can now do the following:
var log = Context.GetLogger()
.ForContext("Address", "No. 4 Privet Drive")
.ForContext("Town", "Little Whinging")
.ForContext("County", "Surrey")
.ForContext("Country", "England");
log.Info("My boss makes me use {Semantic} logging", "semantic");
And it will work without having to explicitly call Context.GetLogger<SerilogLoggingAdapter>()
first.
Building this solution
To run the build script associated with this solution, execute the following:
Windows
c:\> build.cmd all
Linux / OS X
c:\> build.sh all
If you need any information on the supported commands, please execute the build.[cmd|sh] help
command.
This build script is powered by FAKE; please see their API documentation should you need to make any changes to the build.fsx
file.
No packages depend on Akka.Logger.Serilog.
Version | Downloads | Last updated |
---|---|---|
1.5.25 | 27 | 06/27/2024 |
1.5.12.1 | 20 | 03/18/2024 |
1.5.12 | 14 | 03/18/2024 |
1.5.7 | 32 | 06/14/2023 |
1.5.0.1 | 9 | 04/09/2024 |
1.5.0 | 11 | 06/14/2023 |
1.5.0-beta5 | 7 | 04/09/2024 |
1.4.42 | 8 | 08/29/2023 |
1.4.26 | 39 | 03/30/2022 |
1.4.25 | 9 | 07/24/2022 |
1.4.17 | 23 | 07/21/2022 |
1.4.11 | 12 | 07/24/2022 |
1.4.10 | 12 | 07/24/2022 |
1.4.8 | 10 | 07/24/2022 |
1.4.3 | 16 | 07/24/2022 |
1.4.1 | 9 | 07/24/2022 |
1.4.1-rc3 | 12 | 07/24/2022 |
1.4.1-RC1 | 19 | 07/24/2022 |
1.3.11 | 13 | 07/24/2022 |
1.3.10 | 11 | 07/24/2022 |
1.3.9 | 24 | 07/24/2022 |
1.3.6 | 9 | 07/24/2022 |
1.3.3 | 33 | 07/24/2022 |
1.3.0 | 12 | 07/24/2022 |
1.2.0 | 13 | 07/24/2022 |
1.1.3 | 10 | 07/24/2022 |
1.1.2 | 10 | 07/24/2022 |
1.1.1 | 11 | 07/24/2022 |
1.0.8 | 11 | 07/24/2022 |
1.0.7 | 11 | 07/24/2022 |
1.0.6 | 15 | 07/24/2022 |
1.0.5 | 9 | 07/23/2022 |
1.0.4 | 11 | 07/23/2022 |
1.0.3 | 10 | 07/23/2022 |
1.0.2 | 9 | 07/23/2022 |
1.0.1 | 9 | 07/23/2022 |
1.0.0 | 10 | 07/23/2022 |
1.0.0-dev1504032244 | 10 | 07/23/2022 |
0.8.0 | 10 | 07/24/2022 |
0.7.1 | 9 | 07/23/2022 |
0.7.0 | 12 | 07/23/2022 |