Skip to content

Log every use case and unexpected GraphQL errors - #47

Merged
stphnwlsh merged 1 commit into
mainfrom
feature/logging
Nov 3, 2026
Merged

stphnwlsh merged 1 commit into
mainfrom
feature/logging

Conversation

@stphnwlsh

@stphnwlsh stphnwlsh commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Until now nothing we wrote logged anything. This gives each request a clear trail, the same as CleanMinimalApi #66.

  • LoggingBehaviour wraps every use case and logs how it ended, at Information, with the request name and its time in milliseconds: handled, failed validation (with the property names, never the values) or found nothing. It's registered before ValidationBehaviour, so it sees validation failures too. The messages are [LoggerMessage] source-generated, and the time comes from TimeProvider.
  • Unexpected errors are logged. Hot Chocolate hands them to the client as "Unexpected Execution Error" and logs nothing. ApplicationErrorFilter now logs them as Error, with the exception and the field path. Hot Chocolate builds the filter from the schema's own services, so ProgramExtensions gives it the application's logger through GetRootServiceProvider().
  • Information is the default level, and appsettings.local.json lowers it to Debug.
  • TimeProvider.System is registered with TryAddSingleton in both AddApplication and AddInfrastructure, so each layer works on its own without registering the clock twice.
  • FakeLogger (Microsoft.Extensions.Diagnostics.Testing, MIT) checks the messages in the behaviour and filter tests.
  • The serilog, mediator, time-provider, errors-and-exceptions, unit-tests and api-conventions skills describe all of this.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 3, 2026
@stphnwlsh stphnwlsh self-assigned this Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Build Pipeline

✅ Ready to merge. Every stage passed.

Stage Result Details
Build 🟢 Passed Version 2026.11.03.163-pr-47 · Template package 198 KB
Test 🟢 Passed 201 passed · 0 failed · 0 skipped · Template installs, builds and passes its tests
Coverage 🟢 Passed 100% (582 of 582 lines) · Needs 95%
Static Analysis 🟢 Passed No open CodeQL alerts
Dependency Review 🟢 Passed 0 vulnerable packages · 0 licence problems
Container Scan 🟢 Passed Image starts and answers · No open Trivy alerts

Commit 84d8add · Full run

@stphnwlsh
stphnwlsh merged commit 5c642e4 into main Nov 3, 2026
13 checks passed
@stphnwlsh
stphnwlsh deleted the feature/logging branch November 3, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

1 participant