Skip to content

Instantly share code, notes, and snippets.

@Danthar
Last active April 19, 2016 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Danthar/b6b6afc9a2ec5583977191f6c9835fe1 to your computer and use it in GitHub Desktop.
Save Danthar/b6b6afc9a2ec5583977191f6c9835fe1 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka"/>
</configSections>
<akka>
<hocon>
akka {
stdout-loglevel = DEBUG
logLevel = DEBUG
}
</hocon>
</akka>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
class Program
{
static void Main(string[] args) {
var system = ActorSystem.Create("LoggingTest", ConfigurationFactory.Load());
Console.WriteLine("System loglevel: "+system.Settings.LogLevel);
var a = system.ActorOf<LogTestActor>();
do
{
a.Tell("test");
var s = Console.ReadLine();
if (s == "stop")
break;
} while (true);
system.Terminate().Wait();
}
}
public class LogTestActor : ReceiveActor {
public LogTestActor() {
Receive<string>(s => {
Console.WriteLine($"DebugEnabled: {Context.GetLogger().IsDebugEnabled}");
Console.WriteLine($"InfoEnabled: {Context.GetLogger().IsInfoEnabled}");
Console.WriteLine($"ErrorEnabled: {Context.GetLogger().IsErrorEnabled}");
Console.WriteLine($"WarningEnabled: {Context.GetLogger().IsWarningEnabled}");
var logger = Context.GetLogger();
logger.Debug("Debug stuff");
logger.Info("Info stuff");
logger.Error("Error stuff");
logger.Warning("Warning stuff");
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment