Skip to content

Commit

Permalink
Merge pull request #4 from DFE-Digital/feature/formatting-correlation…
Browse files Browse the repository at this point in the history
…-in-logs

fix to logging output format so field is delimited by a : char
  • Loading branch information
chrisdexnimble committed Jul 7, 2023
2 parents 2b44c04 + 79eb299 commit d4a6b12
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Task Invoke(HttpContext httpContext, ICorrelationContext correlationConte
correlationContext.SetContext(thisCorrelationId);

httpContext.Response.Headers[Keys.HeaderKey] = thisCorrelationId.ToString();
using (_logger.BeginScope("x-correlationId {x-correlationId}", correlationContext.CorrelationId.ToString()))
using (_logger.BeginScope("x-correlationId: {x-correlationId}", correlationContext.CorrelationId.ToString()))
{
return _next(httpContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageTags>dfe;academisation;correlation;</PackageTags>
<UserSecretsId>4ac4e7ef-aaff-48a4-9e4d-44371c231191</UserSecretsId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>2.0.0</Version>
<Version>2.0.1</Version>
<Authors>DFE-Digital</Authors>
</PropertyGroup>

Expand Down
3 changes: 3 additions & 0 deletions correlationIdMiddleware/correlationIdMiddleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ CorrelationIds that are passed between services and recorded in all logs help to

* Anywhere that you need access to the current correlation id, inject `ICorrelationContext` and access the current context using the `CorrelationId` property. It will return a `string?` that you can use in subsequent requests or wherever you need it.

## Change Log
See ReleaseNotes.md

---

## Default AspNet Logger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 2.0.1
Fix to the log output so that `x-correlationId [guid]` is now `x-correlationId: [guid]

# 2.0.0
Introduced logging scope output.
Changed to only support GUID correlation ids (breaking changes)

# 1.0.0
Initial version

0 comments on commit d4a6b12

Please sign in to comment.