Skip to content

Commit f485d74

Browse files
Provide Microsoft.Extensions.Logging.AzureAppServices package README (#57824)
1 parent 48a72f2 commit f485d74

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## About
2+
3+
`Microsoft.Extensions.Logging.AzureAppServices` provides a logger implementation that logs to text files in an Azure App Service app's file system and to blob storage in an Azure Storage account.
4+
5+
## Key Features
6+
7+
* Loging messages with the "Diagnostics Logger" and "Log Streaming" features of Azure App Service
8+
* Integration with Azure App Service logging infrastructure
9+
* Seamless integration with other components of `Microsoft.Extensions.Logging`
10+
11+
## How to Use
12+
13+
To use `Microsoft.Extensions.Logging.AzureAppServices`, follow these steps:
14+
15+
### Installation
16+
17+
```shell
18+
dotnet add package Microsoft.Extensions.Logging.AzureAppServices
19+
```
20+
21+
### Configuration
22+
23+
To configure provider settings, use `AzureFileLoggerOptions` and `AzureBlobLoggerOptions`, as shown in the following example:
24+
25+
```csharp
26+
using Microsoft.Extensions.Logging.AzureAppServices;
27+
28+
var builder = WebApplication.CreateBuilder();
29+
builder.Logging.AddAzureWebAppDiagnostics();
30+
builder.Services.Configure<AzureFileLoggerOptions>(options =>
31+
{
32+
options.FileName = "azure-diagnostics-";
33+
options.FileSizeLimit = 50 * 1024;
34+
options.RetainedFileCountLimit = 5;
35+
});
36+
builder.Services.Configure<AzureBlobLoggerOptions>(options =>
37+
{
38+
options.BlobName = "log.txt";
39+
});
40+
```
41+
42+
## Main Types
43+
44+
* `FileLoggerProvider`: A `BatchingLoggerProvider` which writes out to a file
45+
* `BlobLoggerProvider`: The `ILoggerProvider` implementation that stores messages by appending them to Azure Blob in batches
46+
* `AzureFileLoggerOptions`: Options for configuring Azure diagnostics file logging
47+
* `AzureBlobLoggerOptions`: Options for configuring Azure diagnostics blob logging
48+
49+
## Additional Documentation
50+
51+
For additional documentation and examples, refer to the [official documentation](https://learn.microsoft.com/aspnet/core/fundamentals/logging#azure-app-service) on logging with ASP.NEt Core and Azure App Service.
52+
53+
## Feedback &amp; Contributing
54+
55+
`Microsoft.Extensions.Logging.AzureAppServices` is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)