This is a minimal ASP.NET Core Web API application created to demonstrate:
- Controllers and minimal endpoints
- Background services
- Structured logging using Serilog
- Logging to multiple sinks (Console and File)
- .NET SDK 8.0 or later
- Git
From the project root:
dotnet restore dotnet run
Health Check (Minimal API) GET /health
Sample Controller Endpoint GET /api/sample/hello?name=Hello
Background Service The application includes a background service (HeartbeatBackgroundService) that:
- Starts when the application starts
- Logs a heartbeat message every 10 seconds
- Stops gracefully when the application shuts down
Serilog is configured via appsettings.json with two active sinks:
- Console
- File
Log File Location Logs/log-YYYYMMDD.txt
Start the application:
- dotnet run
Observe logs in:
-
The terminal (console sink)
-
The Logs/ folder (file sink)
-
Call the endpoint: GET /api/sample/hello?name=Test
Watch new log entries appear in both sinks.
This is a minimal ASP.NET Core Web API application created to demonstrate:
- Controllers and minimal endpoints
- Background services
- Structured logging using Nlog
- Logging to multiple sinks (Console and File)
- .NET SDK 8.0 or later
- Git
From the project root:
dotnet restore dotnet run
Health Check (Minimal API) GET /health
Sample Controller Endpoint GET /api/sample/hello?name=Hello
Background Service The application includes a background service (HeartbeatBackgroundService) that:
- Starts when the application starts
- Logs a heartbeat message every 10 seconds
- Stops gracefully when the application shuts down
Serilog is configured via nlog.config with two active sinks:
- Console
- File
Log File Location Logs/test.log.tsx
Start the application:
- dotnet run
Observe logs in:
-
The terminal (console sink)
-
The Logs/ folder (file sink)
-
Call the endpoint: GET /api/sample/hello?name=Test
Watch new log entries appear in both sinks.