Benutzer:MovGP0/Akka.NET/Logging
aus Wikipedia, der freien Enzyklopädie
< Benutzer:MovGP0 | Akka.NET
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Akka.NET LoggingNuGet Packages
Usagepublic class MyActor : ReceiveActor
{
private ILoggingAdapter Log { get; } = Context.GetLogger();
public MyActor()
{
Receive<MyMessage>(OnMyMessage);
}
private void OnMyMessage(MyMessage message)
{
Log.Info("Got message {0}", message.Content);
try
{
// do something
}
catch(Exception ex)
{
Log.Error(ex, ex.Message);
throw;
}
}
}
Configuration
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configsections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
<!-- ... -->
</configsections>
<akka>
<hocon>
<![CDATA[
akka {
stdout-loglevel = DEBUG
loglevel = WARN
log-config-on-start = on
loggers = ["Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog", "Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog", "..."]
actor { # logging akka events
debug { # debug level and above
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
}
]]>
</hocon>
</akka>
<!-- NLog configuration -->
<!-- ... -->
</configuration>
Log Levels
see also: Logging |