Skip to content

Commit

Permalink
docs: remove 'clear logging providers' from preview & published docs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels authored Mar 30, 2022
1 parent 8f33d7c commit f147176
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/preview/03-Guidance/use-with-dotnet-and-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Some aspects we would like to highlight are:
- Make sure to call [`UseSerilog`](https://www.nuget.org/packages/Serilog.AspNetCore) when creating a `IHostBuilder`
- Remove default for logging including its configuration in `appsettings.json` *(if applicable)*

If you cannot use `UseSerilog`, you can still configure it by using `AddSerilog` as a logging provider; but we recommend removing all other providers with `loggingBuilder.ClearProviders()` so that they don't interfere.

## Setting up Serilog with Azure Functions

Using Serilog with Azure Functions requires some guidance and we've made it a bit easier to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ Some aspects we would like to highlight are:
- Make sure to call [`UseSerilog`](https://www.nuget.org/packages/Serilog.AspNetCore) when creating a `IHostBuilder`
- Remove default for logging including its configuration in `appsettings.json` *(if applicable)*

If you cannot use `UseSerilog`, you can still configure it by using `AddSerilog` as a logging provider; but we recommend removing all other providers with `loggingBuilder.ClearProviders()` so that they don't interfere.

## Setting up Serilog with Azure Functions

Using Serilog with Azure Functions requires some guidance and we've made it a bit easier to use.
Expand Down Expand Up @@ -54,16 +52,13 @@ namespace Arcus.Samples.AzureFunction

builder.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProvidersExceptFunctionProviders();
loggingBuilder.AddSerilog(logger);
});
}
}
}
```

> :bulb: Note that we are using `ClearProvidersExceptFunctionProviders` instead of `ClearProviders` given Azure Functions requires some logging providers to be available.
Here is an example of how you can use ILogger to write multi-dimensional metrics with Arcus. If Serilog would not be setup correctly (see above), it would only report the metric without the dimensions.

```csharp
Expand Down

0 comments on commit f147176

Please sign in to comment.