cdlm
cdlm

Reputation: 575

How do you properly configure a contrib logger?

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?

Upvotes: 4

Views: 870

Answers (2)

Aaronontheweb
Aaronontheweb

Reputation: 8414

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"]
}

Upvotes: 5

Bartosz Sypytkowski
Bartosz Sypytkowski

Reputation: 7542

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.

Upvotes: 2

Related Questions