Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/nuget/source/JsonSerialization/so…
Browse files Browse the repository at this point in the history
…urce/JsonSerialization/System.Text.Json-6.0.10
  • Loading branch information
Sondergaard authored Oct 11, 2024
2 parents 90bfb95 + 234b244 commit ba872f6
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions source/Logging/documents/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ Request and response stream should be seekable for the middleware to read stream

Implementation example:

builder.UseMiddleware<RequestResponseLoggingMiddleware>();
```c#
builder.UseMiddleware<RequestResponseLoggingMiddleware>();
```

---

Container.Register<RequestResponseLoggingMiddleware>(Lifestyle.Scoped);
``` c#
Container.Register<RequestResponseLoggingMiddleware>(Lifestyle.Scoped);
```

---

serviceCollection.AddScoped<IRequestResponseLogging>(
``` c#
serviceCollection.AddScoped<IRequestResponseLogging>(
_ => new RequestResponseLoggingBlobStorage(connectionString,
containerName,
ILogger<RequestResponseLoggingBlobStorage>));
```

## App Release notes

Expand All @@ -35,43 +43,43 @@ Install `Energinet.DataHub.Core.Logging.LoggingMiddleware` package.

**Registration for Function app:**

```c#
public static IHost ConfigureApplication()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(ConfigureWorker)
.ConfigureServices(ConfigureServices)
.ConfigureLogging(ConfigureLogging)
.Build();
return host;
}

private static void ConfigureWorker(IFunctionsWorkerApplicationBuilder builder)
{
builder.UseLoggingScope();
}

private static void ConfigureServices(HostBuilderContext context, IServiceCollection serviceCollection)
{
serviceCollection.AddFunctionLoggingScope("domain-name");
}

private static void ConfigureLogging(ILoggingBuilder builder)
{
builder.SetApplicationInsightLogLevel();
}
```
```c#
public static IHost ConfigureApplication()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(ConfigureWorker)
.ConfigureServices(ConfigureServices)
.ConfigureLogging(ConfigureLogging)
.Build();
return host;
}

private static void ConfigureWorker(IFunctionsWorkerApplicationBuilder builder)
{
builder.UseLoggingScope();
}

private static void ConfigureServices(HostBuilderContext context, IServiceCollection serviceCollection)
{
serviceCollection.AddFunctionLoggingScope("domain-name");
}

private static void ConfigureLogging(ILoggingBuilder builder)
{
builder.SetApplicationInsightLogLevel();
}
```

**Registration for Web app:**

```c#
public void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddHttpLoggingScope("domain-name");
}
public void Configure(IApplicationBuilder app)
{
app.UseLoggingScope();
}
```
``` c#
public void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddHttpLoggingScope("domain-name");
}

public void Configure(IApplicationBuilder app)
{
app.UseLoggingScope();
}
```

0 comments on commit ba872f6

Please sign in to comment.