Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you properly configure a contrib logger?

Tags:

c#

akka.net

The Wiki is vague in describing how to configure a logger. I'm using

var config = ConfigurationFactory.ParseString(@"
    akka {
        loggers = [""Akka.NLog.Event.NLog.NLogLogger,Akka.NLog""]
        stdout-loglevel = INFO
        loglevel = INFO
        log-config-on-start = on
    }"
);

and have installed Akka.NLog from Nuget but get an exception when I create the actor system stating 'Logger specified in config cannot be found: "Akka.NLog.Event.NLog.NLogLogger,Akka.NLog"'.

What is the correct configuration string for a contrib logger?

like image 538
cdlm Avatar asked Mar 19 '23 08:03

cdlm


2 Answers

The correct HOCON configuration should look like this:

akka {
  loggers = ["Akka.Logger.NLog.NLogLogger,Akka.Logger.NLog"]
}

To configure a custom logger, you just need to pass in a FQN into the akka.loggers HOCON field.

So if you want to use a user-defined logger Foo.Loggers.MyCustomLogger in assembly Foo.Loggers AND your original NLog logger, your HOCON will look like this:

akka {
  loggers = ["Foo.Loggers.MyCustomLogger,Foo.Loggers","Akka.Logger.NLog.NLogLogger,Akka.Logger.NLog"]
}
like image 113
Aaronontheweb Avatar answered Apr 01 '23 11:04

Aaronontheweb


Your exception points out, that fully qualified type name for logger you've used is not correct. Either you haven't provided correct assembly in your project, or type name is invalid.

At the present moment Akka logger with NLog support is now accessible with:

install-package Akka.Logger.NLog

NLog logger itself is accessible with Akka.Logger.NLog.NLogLogger, Akka.Logger.NLog fully qualified name.

like image 35
Bartosz Sypytkowski Avatar answered Apr 01 '23 11:04

Bartosz Sypytkowski