The application uses hierarchical configuration with environment-specific settings. There are two ways the environment is determined:
appsettings.{Environment}.json file is loadedThe DOTNET_ENVIRONMENT environment variable determines which configuration file to load:
# Load appsettings.Development.json
DOTNET_ENVIRONMENT=Development
# Load appsettings.Staging.json
DOTNET_ENVIRONMENT=Staging
# Load appsettings.Production.json (default)
DOTNET_ENVIRONMENT=Production
Based on DOTNET_ENVIRONMENT, .NET loads:
appsettings.json (base configuration)appsettings.{Environment}.json (overrides base)Each environment-specific file defines its own Application:Environment value:
appsettings.Development.json:
{
"Application": {
"Environment": "Development"
},
...
}
appsettings.Production.json:
{
"Application": {
"Environment": "Production"
},
...
}
cd src/EmbaseConferenceScheduler.Worker
# Run with Development settings
dotnet run --environment Development
Result:
appsettings.Development.jsonRun with Production environment:
docker run -d \
-e DOTNET_ENVIRONMENT=Production \
-v /data/production/articles/pdf:/production/articles/pdf:ro \
-v embase-logs:/logs \
--name embase-conference-scheduler \
embase-conference-scheduler:latest
Result:
appsettings.Production.jsonRun with Staging environment:
docker run -d \
-e DOTNET_ENVIRONMENT=Staging \
-v /data/production/articles/pdf:/production/articles/pdf:ro \
-v embase-logs:/logs \
--name embase-conference-scheduler \
embase-conference-scheduler:latest
Result:
appsettings.Staging.jsonYou can inject IOptions<ApplicationSettings> to read the environment:
using EmbaseConferenceScheduler.Domain.Configuration;
using Microsoft.Extensions.Options;
public class MyService
{
private readonly ApplicationSettings _appSettings;
public MyService(IOptions<ApplicationSettings> options)
{
_appSettings = options.Value;
}
public void DoSomething()
{
if (_appSettings.Environment == "Development")
{
// Special dev behavior
}
else if (_appSettings.Environment == "Production")
{
// Production behavior
}
}
}
Settings are loaded in this order (last wins):
Even if appsettings.Production.json says:
{
"ConnectionStrings": {
"EmbaseDb": "Host=prod-db;..."
}
}
You can override at runtime:
# docker-compose.yml
environment:
ConnectionStrings__EmbaseDb: "Host=override-db;Port=5432;..."
| File | Application:Environment | Database | SFTP | CRON Schedule |
|---|---|---|---|---|
appsettings.json |
Production | localhost | sftp.elsevier.com | Daily 02:00 |
appsettings.Development.json |
Development | localhost:embase_dev | localhost:2222 | Every 5 min |
appsettings.Staging.json |
Staging | staging-db | sftp-staging | Daily 03:00 |
appsettings.Production.json |
Production | prod-db | sftp.elsevier.com | Daily 02:00 |
On startup, the application logs the active environment:
[2026-03-09 10:30:15 INF] Starting Embase Conference Abstract Scheduler...
[2026-03-09 10:30:16 INF] Scheduler host built successfully.
[2026-03-09 10:30:16 INF] DOTNET_ENVIRONMENT: Production
[2026-03-09 10:30:16 INF] Application Environment (from appsettings): Production
[2026-03-09 10:30:16 INF] Configuration file loaded: appsettings.Production.json
[2026-03-09 10:30:16 INF] Waiting for Quartz trigger...
| Method | How To Set |
|---|---|
| Command Line | dotnet run --environment Staging |
| Docker Compose | DOTNET_ENVIRONMENT: Staging in environment section |
| Docker Run | docker run -e DOTNET_ENVIRONMENT=Staging ... |
| Windows | $env:DOTNET_ENVIRONMENT="Staging" |
| Linux | export DOTNET_ENVIRONMENT=Staging |
✅ DO:
DOTNET_ENVIRONMENT to control which file loads❌ DON'T:
Application:Environment - use .NET's built-in IHostEnvironmentProblem: Application loads Production settings when you expected Development
Solution:
# Verify DOTNET_ENVIRONMENT is set
echo $env:DOTNET_ENVIRONMENT # Windows
echo $DOTNET_ENVIRONMENT # Linux
# Set it explicitly
dotnet run --environment Development
Problem: Changed appsettings.Development.json but changes don't apply
Possible causes:
dotnet clean; dotnet buildProblem: Logs show:
DOTNET_ENVIRONMENT: Production
Application Environment: Development
This means:
DOTNET_ENVIRONMENT=Productionappsettings.Production.json has wrong Application:Environment valueFor more details, see README_Architecture.md