Benutzer:MovGP0/Akka.NET/Logging
Zur Navigation springen
Zur Suche springen
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
Akka.NET Logging[Bearbeiten | Quelltext bearbeiten]NuGet Packages[Bearbeiten | Quelltext bearbeiten]
Usage[Bearbeiten | Quelltext bearbeiten]public 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[Bearbeiten | Quelltext bearbeiten]
<?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[Bearbeiten | Quelltext bearbeiten]
see also: Logging |