Skip to content

Releases: akkadotnet/Akka.Hosting

0.4.3

10 Sep 15:22
5ebc39b
Compare
Choose a tag to compare

0.4.2

12 Aug 00:33
293e5a9
Compare
Choose a tag to compare

0.4.1

21 Jul 17:14
a52690c
Compare
Choose a tag to compare

Fix Microsoft.Extensions.Logging.ILoggerFactory logging support
Add InMemory snapshot store and journal persistence support

Due to a bad API design, we're rolling back the Microsoft.Extensions.Logging.ILoggerFactory logger support introduced in version 0.4.0, the 0.4.0 NuGet version is now considered as deprecated in support of the new API design introduced in version 0.4.1.

Logger Configuration Support

You can now use the new AkkaConfigurationBuilder extension method called ConfigureLoggers(Action<LoggerConfigBuilder>) to configure how Akka.NET logger behave.

Example:

builder.Services.AddAkka("MyActorSystem", configurationBuilder =>
{
    configurationBuilder
        .ConfigureLoggers(setup =>
        {
            // Example: This sets the minimum log level
            setup.LogLevel = LogLevel.DebugLevel;
            
            // Example: Clear all loggers
            setup.ClearLoggers();
            
            // Example: Add the default logger
            // NOTE: You can also use setup.AddLogger<DefaultLogger>();
            setup.AddDefaultLogger();
            
            // Example: Add the ILoggerFactory logger
            // NOTE:
            //   - You can also use setup.AddLogger<LoggerFactoryLogger>();
            //   - To use a specific ILoggerFactory instance, you can use setup.AddLoggerFactory(myILoggerFactory);
            setup.AddLoggerFactory();
            
            // Example: Adding a serilog logger
            setup.AddLogger<SerilogLogger>();
        })
        .WithActors((system, registry) =>
        {
            var echo = system.ActorOf(act =>
            {
                act.ReceiveAny((o, context) =>
                {
                    Logging.GetLogger(context.System, "echo").Info($"Actor received {o}");
                    context.Sender.Tell($"{context.Self} rcv {o}");
                });
            }, "echo");
            registry.TryRegister<Echo>(echo); // register for DI
        });
});

A complete code sample can be viewed here.

Exposed properties are:

  • LogLevel: Configure the Akka.NET minimum log level filter, defaults to InfoLevel
  • LogConfigOnStart: When set to true, Akka.NET will log the complete HOCON settings it is using at start up, this can then be used for debugging purposes.

Currently supported logger methods:

  • ClearLoggers(): Clear all registered logger types.
  • AddLogger<TLogger>(): Add a logger type by providing its class type.
  • AddDefaultLogger(): Add the default Akka.NET console logger.
  • AddLoggerFactory(): Add the new ILoggerFactory logger.

Microsoft.Extensions.Logging.ILoggerFactory Logging Support

You can now use ILoggerFactory from Microsoft.Extensions.Logging as one of the sinks for Akka.NET logger. This logger will use the ILoggerFactory service set up inside the dependency injection ServiceProvider as its sink.

Microsoft.Extensions.Logging Log Event Filtering

There will be two log event filters acting on the final log input, the Akka.NET akka.loglevel setting and the Microsoft.Extensions.Logging settings, make sure that both are set correctly or some log messages will be missing.

To set up the Microsoft.Extensions.Logging log filtering, you will need to edit the appsettings.json file. Note that we also set the Akka namespace to be filtered at debug level in the example below.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information",
      "Akka": "Debug"
    }
  }
}

InMemory Snapshot Store And Journal Support

You can now use these AkkaConfigurationBuilder extension methods to enable InMemory persistence back end:

  • WithInMemoryJournal(): Sets the InMemory journal as the default journal persistence plugin
  • WithInMemorySnapshotStore(): Sets the InMemory snapshot store as the default snapshot-store persistence plugin.

0.4.0

18 Jul 20:29
2f1683d
Compare
Choose a tag to compare

Add Microsoft.Extensions.Logging.ILoggerFactory logging support

You can now use ILoggerFactory from Microsoft.Extensions.Logging as one of the sinks for Akka.NET logger. This logger will use the ILoggerFactory service set up inside the dependency injection ServiceProvider as its sink.

Example:

builder.Services.AddAkka("MyActorSystem", (configurationBuilder, serviceProvider) =>
{
    configurationBuilder
        .AddHocon("akka.loglevel = DEBUG")
        .WithLoggerFactory()
        .WithActors((system, registry) =>
        {
            var echo = system.ActorOf(act =>
            {
                act.ReceiveAny((o, context) =>
                {
                    Logging.GetLogger(context.System, "echo").Info($"Actor received {o}");
                    context.Sender.Tell($"{context.Self} rcv {o}");
                });
            }, "echo");
            registry.TryRegister<Echo>(echo); // register for DI
        });
});

There are two Akka.Hosting extension methods provided:

  • .WithLoggerFactory(): Replaces all Akka.NET loggers with the new ILoggerFactory logger.
  • .AddLoggerFactory(): Inserts the new ILoggerFactory logger into the Akka.NET logger list.

Log Event Filtering

There will be two log event filters acting on the final log input, the Akka.NET akka.loglevel setting and the Microsoft.Extensions.Logging settings, make sure that both are set correctly or some log messages will be missing.

To set up the Microsoft.Extensions.Logging log filtering, you will need to edit the appsettings.json file. Note that we also set the Akka namespace to be filtered at debug level in the example below.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information",
      "Akka": "Debug"
    }
  }
}

0.3.4

23 Jun 18:43
658c491
Compare
Choose a tag to compare

0.3.3

16 Jun 17:48
67776ce
Compare
Choose a tag to compare

0.3.2

13 Jun 16:48
e1f3317
Compare
Choose a tag to compare

0.3.1

09 Jun 14:44
ed718fd
Compare
Choose a tag to compare

0.3.0

24 May 16:57
86d18b8
Compare
Choose a tag to compare

0.2.2

10 Apr 18:20
8af9b2c
Compare
Choose a tag to compare