Skip to content

Add log filtering integration#460

Merged
Aaronontheweb merged 5 commits into
akkadotnet:devfrom
Arkatufus:Add-log-filtering
Jun 4, 2024
Merged

Add log filtering integration#460
Aaronontheweb merged 5 commits into
akkadotnet:devfrom
Arkatufus:Add-log-filtering

Conversation

@Arkatufus

Copy link
Copy Markdown
Contributor

No description provided.

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about the two different ways of doing this, but otherwise looks good

Comment thread README.md Outdated

In Akka.NET 1.5.21, we introduced [log filtering for log messages based on the LogSource or the content of a log message](https://getakka.net/articles/utilities/logging.html#filtering-log-messages). Depending on your coding style, you can use this feature in Akka.Hosting in several ways.

1. Using the `WithLogFilter()` `AkkaConfigurationBuilder` extension method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread README.md Outdated
});
```

2. Using The `LoggerConfigBuilder.WithLogFilter()` method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

[Fact(DisplayName = "WithLogFilter should inject LogFilterSetup")]
public void WithLogFilterSetupTest()
{
var builder = new AkkaConfigurationBuilder(new ServiceCollection(), "fake")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

return this;
}

public LoggerConfigBuilder WithLogFilter(Action<LogFilterBuilder> filterBuilder)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm not so sure about - what happens if someone calls this and ConfigureLogging (or whatever it's called?) - can't we end up with one config overriding the other?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the two implementation inside ConfigureLoggers(builder) and the extension method AkkaConfigurationBuilder.WithLogFilter() is exclusive to each other. The first being added would win because of how we retrieve Setup classes in ActorSystem.Settings

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we decided to stick with just the LogConfigBuilder.

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (once API approvals are in)

Comment thread README.md Outdated
builder.Services.AddAkka("MyActorSystem", configurationBuilder =>
{
configurationBuilder
.WithLogFilter(filterBuilder =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - glad we consolidated this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants