📄 Documentation: IrbyImaging/appsettings.Development.json
🗂 Table of Contents
- 🎯 Overview & Purpose
- 🔧 Configuration Structure
- 📝 Key Configuration Settings
- 🚀 How It Works
- 4.1 .NET Core Logging Pipeline
- 4.2 Reading the Settings
- 💻 Usage Examples
- 🔌 Dependencies & Technologies
- 📈 Best Practices & Tips
- 🔄 Environment‑Specific Configurations
- 📝 Conclusion
1. 🎯 Overview & Purpose
The appsettings.Development.json file is a JSON‑based configuration file used by ASP.NET Core applications (like IrbyImaging) to specify settings for the Development environment.
- Why have a separate Development file?
- Keeps development‑only settings (e.g., verbose logging) isolated from production.
- Automatically loaded after
appsettings.jsonwhenASPNETCORE_ENVIRONMENT=Development. - Allows developers to troubleshoot without impacting production behavior.
2. 🔧 Configuration Structure
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
Breakdown of the JSON hierarchy:
- Logging
- Top‑level section controlling the entire logging subsystem.
- LogLevel
- Nested section specifying minimum logging levels per category.
3. 📝 Key Configuration Settings
| Section | Key | Description | Default (Dev) |
|---|---|---|---|
| Logging | — | Root of logging configuration | — |
| LogLevel | Default | Global minimum level (applies to all categories unless overridden) | Information |
| Microsoft | Overrides for logs coming from Microsoft.* namespaces |
Warning | |
| Microsoft.Hosting.Lifetime | Overrides for hosting lifecycle logs (startup, shutdown, health checks) | Information |
4. 🚀 How It Works
4.1 .NET Core Logging Pipeline
- Configuration Loading
- ASP.NET Core reads
appsettings.json - It then overrides using
appsettings.{Environment}.json(here,Development)
- ASP.NET Core reads
- Logging Providers (e.g., Console, Debug)
- Configured in
Program.cs/Startup.cs - Respect the LogLevel settings
- Configured in
- Log Factory
- Creates loggers by category (e.g., controllers, middleware)
- Filters out messages below the configured level
4.2 Reading the Settings
- Via
IConfigurationpublic class Startup { private readonly IConfiguration _configuration; public Startup(IConfiguration configuration) { _configuration = configuration; } public void ConfigureServices(IServiceCollection services) { var defaultLevel = _configuration["Logging:LogLevel:Default"]; // defaultLevel == "Information" } } - Via
IOptions<T>public class LoggingSettings { public LogLevelSettings LogLevel { get; set; } } public class LogLevelSettings { public string Default { get; set; } public string Microsoft { get; set; } public string Microsoft_Hosting_Lifetime { get; set; } } // In Program.cs / Startup.cs services.Configure<LoggingSettings>(Configuration.GetSection("Logging"));
5. 💻 Usage Examples
5.1 Configure Logging in Program.cs (ASP.NET Core 6+)
var builder = WebApplication.CreateBuilder(args);
// Load all appsettings*.json including appsettings.Development.json
builder.Logging.ClearProviders();
builder.Logging.AddConsole();
builder.Logging.AddDebug();
// Logging levels are read automatically from configuration
// No manual mapping needed.
var app = builder.Build();
app.MapGet("/", () => "Hello, IrbyImaging!");
app.Run();
5.2 Overriding at Runtime
You can override any of these settings using:
- Environment variables
set Logging__LogLevel__Default=Debug - Command‑line arguments
dotnet run --Logging:LogLevel:Default=Debug
6. 🔌 Dependencies & Technologies
- .NET Core / .NET 6+
Uses built‑in configuration and logging abstractions. - Microsoft.Extensions.Configuration
- JSON file support
- Environment overrides
- Microsoft.Extensions.Logging
- Provider‑based logging
- Category filtering
7. 📈 Best Practices & Tips
- Use environment‑specific files (
Development,Staging,Production). - Keep sensitive data out of JSON. Use User Secrets or environment variables.
- Set production log level to Warning or Error to reduce noise.
- Use structured logging (e.g., message templates) to enrich your logs.
8. 🔄 Environment‑Specific Configurations
appsettings.json # Base settings (all environments)
appsettings.Development.json # Overrides for Development
appsettings.Staging.json # Overrides for Staging
appsettings.Production.json # Overrides for Production
Note: Order of loading
appsettings.jsonappsettings.{Environment}.json- Environment variables
- Command‑line args
9. 📝 Conclusion
The appsettings.Development.json file in IrbyImaging centralizes all development‑only logging configurations. By adjusting LogLevel values here, you can:
- Control verbosity during development
- Filter out unwanted noise from Microsoft libraries
- Fine‑tune the host lifecycle logs
This approach keeps your main appsettings.json clean and your production environment safe from overly verbose logging. Happy debugging! 🛠🎉
🔍 Appendix: UML Diagram of Configuration Structure
@startuml
class AppSettings {
+ Logging : LoggingSection
}
class LoggingSection {
+ LogLevel : LogLevelSection
}
class LogLevelSection {
+ Default : string
+ Microsoft : string
+ Microsoft.Hosting.Lifetime: string
}
AppSettings --> LoggingSection
LoggingSection --> LogLevelSection
@enduml