Logging
The default providers are cleared and two are added: a console provider, and DailyFileLoggerProvider,
which writes one file per instance and per day, log-{environment}-{yyyy-MM-dd}.txt, in the directory
Logging:File:Directory names — logs by default, a relative path being taken from the process's
current working directory — and deletes this instance's files older than Logging:File:RetainDays,
30 by default. The same provider instance is registered as a singleton, which is how the log endpoints
read today's file through it. It swallows every I/O failure, on the principle that logging must not
fault a request or a startup; Log Viewer Page covers its naming, its fallbacks and its writer.
The two providers are filtered independently. The file provider's alias is File, so a
Logging:File:LogLevel section configures it alone, while the console follows the provider-neutral
Logging:LogLevel section, which the shipped configuration sets to Warning. The host seeds five file
rules in code — Information by default; Warning for Microsoft and System; Information for
Microsoft.Hosting.Lifetime, so the host's start lines (listening address, environment, content root)
reach the file; and Information for Microsoft.AspNetCore.HostFiltering, so a request that host
filtering refuses with a bare 400 leaves the refused host name there — and it inserts them
ahead of the rules built from configuration rather than adding them after. On a tie the later rule
wins, so any configured Logging:File:LogLevel key overrides its seeded default, while a deployment
whose configuration has no File section still gets the seeded levels rather than the console's. The
shipped appsettings.json spells the first four of those levels out, and the Development overlay adds
None for the development-time BrowserLink and browser-refresh middleware. The environment-variable
provider reaches the same keys: Logging__File__LogLevel__Default=Warning leaves only warnings and
worse in the file, apart from the host's Microsoft.Hosting.Lifetime lines and the host-filtering
refusals, which their own, more specific Information rules still admit (set
Logging__File__LogLevel__Microsoft.Hosting.Lifetime=Warning and
Logging__File__LogLevel__Microsoft.AspNetCore.HostFiltering=Warning as well to drop them).
RunApp writes a startup summary line just before it runs the application — the instance
(environment name), the build, the REST API version, the working directory, the admin directory and
whether the login gate is on — so the file for the day the service starts has content before the first
request arrives. That guarantee stops at midnight: the writer opens the file named for each entry's
date and creates nothing ahead of time, so a host left running into a new day has no file for it until
the next entry is written.
Three more sources feed the log from the host itself. AppDomain.CurrentDomain.UnhandledException is
logged Critical and TaskScheduler.UnobservedTaskException Error, so a crash on a background thread or
a faulted task nobody awaited leaves a line. The native core's log function is routed into a logger of
category Hi.Native, at a level read off each line's wording: a licence failure is Critical; a refused
NC composition, no usable GL, a shader that will not build, an EGL display that will not open or
initialise, and a GL debug message of high severity or error type are Error; Mesa software
rasterisation, the picking-table ceiling, medium-severity GL messages, a line asked wider than the
driver draws and a drawing skipped for its primitive mode are Warning; the OpenGL context record, the
line width range and frame statistics stay Information. And AppBegin's logger
(Program and Hosting) carries the
library's licence abort line at Critical.
The host never disposes a provider registered as an instance, so the shutdown path handles this one
itself: it flushes the queue just before AppEnd, so a crash inside the native teardown still leaves
the line announcing it, and shuts the writer down after AppEnd — in RunApp's exit path and in the
ProcessExit handler alike — after which lines are written synchronously.
Source Code Path
See HiNC App Anatomy for git repository links.
Web Application
HiNC-2025-webservice (Quasar CLI SPA):
Program.cs— creates the file log provider, seeds its default rules, writes the startup summary line, hooks the two exception handlers, maps native-core lines ontoHi.Nativelevels, and flushes and shuts the writer down around the native teardown.Common/DailyFileLoggerProvider.cs— the per-instance, per-day file logger under theFilealias, which the log endpoints read back through.appsettings.json— the shippedLogging:Filesection: its levels, directory and retention.appsettings.Development.json— the Development overlay's twoLogging:File:LogLevelkeys.Environments/ProjectController.cs— the log endpoints that read today's file through the provider.
HiAPI Engine
HiNc/HiNcKits/LocalApp.cs— the licence abort lineAppBeginlogs at Critical on the logger it is given.
See Also
- Program and Hosting — the host that registers these providers, and the shutdown the flush is bracketed by
- Configuration — the
Loggingkeys, and the environment name that names the log file - Log Viewer Page — the page that reads the file this provider writes, and what that file holds