Skip to content

SmrtHub Logging Setup (Plain-English)

This explains how the SmrtHub logger is configured and where things live.

  • Logger outputs (what the app writes):
  • Log files: by default under %AppData%/SmrtHub/Logs/<component>/
    • Example: C:\Users\<you>\AppData\Roaming\SmrtHub\Logs\smrthub-ui\smrthub-ui-log.json and .txt
  • Optional console output (for development)

  • Logger configuration (how you control it):

  • You set it in your app's appsettings.json under the section Logging:SmrtHub.
  • This file is part of the app project, not created in AppData.
  • Users don't need to edit it; you ship good defaults. You can still override with environment variables if needed.

Where appsettings.json lives

  • It should be checked into the app project (e.g., your WinUI3 or service project).
  • Typical path: <YourAppProject>/appsettings.json.
  • We do not create or read config from AppData. AppData is only used to store log files.

Minimal example (drop into appsettings.json)

{ "Logging": { "SmrtHub": { "MinimumLevel": "Information", "LogDirectory": "", // empty => use AppData default per component "RetainedFileCountLimit": 14, "FileSizeLimitBytes": 10485760, "RollOnFileSizeLimit": true, "ScrubPII": true, "RedactionToken": "[REDACTED]", "EnableConsole": false } } }

Wiring it at startup

  • Build configuration (Host/Minimal or a simple ConfigurationBuilder)
  • Call: Logger.ConfigureFrom(configuration, "YourComponentName")

That’s it. Change settings in appsettings.json and rebuild; the app picks them up without code changes.