MariaServiceHoster Logging
MariaServiceHoster supports a shared logging policy for the hoster, built-in GDK services and approved external child services. The policy covers minimum levels, category overrides, file paths, rolling intervals, size-based rolling and file retention.
The configuration is framework-neutral. The hoster and GDK-owned services use a Serilog adapter, but external services do not have to use Serilog or depend on the hoster's setup helpers.
Configuration files
Use the logging sidecars beside the selected host configuration file:
appSettings.Logging.jsonfor shared deployment defaults.appSettings.Logging.Local.jsonfor machine-specific overrides.
Both files are optional. Logging settings in the base configuration or other loaded sidecars remain supported.
When starting the host with a differently named configuration file, use matching sidecar names. For example, production.json uses production.Logging.json and production.Logging.Local.json.
The configuration load order is shown below. Later files override earlier values for the same key.
<base>.json<base>.Proxy.json<base>.ExternalProcesses.json<base>.ServiceSettings.json<base>.Logging.json<base>.Local.json<base>.Proxy.Local.json<base>.ExternalProcesses.Local.json<base>.ServiceSettings.Local.json<base>.Logging.Local.json
Restart the hoster to apply configuration changes to the hoster and its child services. Logging sidecars are not applied through live reload.
Shared defaults and process overrides
| Section | Applies to |
|---|---|
Logging |
Shared defaults for the hoster and all child services. |
HosterLogging |
Overrides shared defaults for the hoster only. |
HostedServices:<ServiceId>:Logging |
Overrides shared defaults for one child service. |
The hoster resolves each process's policy independently. Hoster-only overrides are never passed to children. Overrides merge by setting and category key; overriding one category does not remove other inherited categories.
File precedence and process precedence are separate: first the configuration files are combined, then the relevant process-specific section is merged over Logging.
Available settings
All settings below are relative to Logging. The same structure can be used under HosterLogging or a child's Logging section.
| Setting | Default | Description |
|---|---|---|
LogPath |
Not set in the options model | File path. File logging requires a non-empty path. |
DisableFileSink |
false |
Set to true to disable file output. Console output remains enabled, subject to minimum levels.
|
LogLevel:Default |
Information |
Default minimum log level. |
LogLevel:<Category> |
Inherited | Minimum level for a category and its dot-separated descendants. |
File:RollingInterval |
Day |
Calendar rolling interval: Infinite, Year, Month, Day, Hour or Minute. Infinite disables calendar rolling.
|
File:FileSizeLimitBytes |
1073741824 (1 GiB) |
Positive file-size threshold in bytes. |
File:RollOnFileSizeLimit |
false |
Set to true to open a new file when the size limit is reached.
|
File:RetainedFileCountLimit |
31 |
Positive maximum retained file count, including the active file. Counts both calendar-generated files and size-generated chunks for the same log path. |
The supplied base configuration sets LogPath to:
%ProgramData%\TeleplanGlobe\MariaServiceHoster\Logs\[service_tag].log
The host replaces [service_tag] with Hoster or the actual child instance id before launch. Environment variables in the path are also expanded. For example, a child named GeoObjectStore uses its own GeoObjectStore log file series.
Use a distinct path for each process so files and retention remain independent. Ensure the service account can write to the log directory.
The supplied base configuration also sets Microsoft.AspNetCore and Yarp.ReverseProxy to Warning. These are configuration defaults, not hard-coded category restrictions.
Minimum levels and category overrides
Supported levels, from most verbose to least verbose, are:
Trace, Debug, Information, Warning, Error, Critical, None
Level names are case-insensitive. Legacy Verbose and Fatal are accepted as aliases for Trace and Critical.
Category matching is case-sensitive. The longest matching dot-separated category prefix wins. For example:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.AspNetCore": "Error"
}
}
}
Here, Microsoft.AspNetCore.Hosting requires Error or higher, while other Microsoft categories require Warning or higher.
None disables logging for the matching category. A more-specific category override can enable logging again.
Invalid levels, invalid intervals and non-positive size or retention limits are rejected rather than silently ignored.
Daily and size rolling together
Daily rolling and size rolling operate simultaneously when RollingInterval is Day and RollOnFileSizeLimit is true.
Daily rolling uses the process's local calendar day. A new daily file opens on the next event after the boundary, rather than through a timer that creates empty files.
Retention counts files, not days. With a 100 MB size limit and five retained files:
- At approximately 10 MB per day, five retained daily files normally represent five days with log activity.
- At approximately 500 MB per day, the latest five chunks may all belong to the current day.
Retention removes the oldest files as new files open. It is not a guaranteed number of days or a strict disk quota. An individual event can exceed the size threshold.
Compatibility default: RollOnFileSizeLimit remains false. With this setting, file output stops when the size threshold has been reached until the next calendar roll. Set it to true to continue in another file. With RollingInterval set to Infinite, there is no calendar roll to resume output.
Example: 100 MB files and five retained files
Place the following in appSettings.Logging.Local.json. This example uses decimal MB: 100 MB is 100,000,000 bytes.
{
"Logging": {
"LogPath": "%ProgramData%\\TeleplanGlobe\\MariaServiceHoster\\Logs\\[service_tag].log",
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Yarp.ReverseProxy": "Warning"
},
"File": {
"RollingInterval": "Day",
"FileSizeLimitBytes": 100000000,
"RollOnFileSizeLimit": true,
"RetainedFileCountLimit": 5
}
},
"HosterLogging": {
"LogLevel": {
"Default": "Warning"
}
},
"HostedServices": {
"GeoObjectStore": {
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}
}
}
The hoster uses Warning as its default minimum level, GeoObjectStore uses Debug, and other children inherit Information. All inherit the same file rolling and retention settings and use separate file names through [service_tag].
A matching example is supplied as appSettings.Logging.Local.example.json.
External service integration
The host sends each child its resolved Logging section through the configured child transport:
- Environment variables prefixed with
MARIA_HOSTED__. - A generated configuration file passed using
--config, when file transport is selected.
For example:
MARIA_HOSTED__Logging__LogPath MARIA_HOSTED__Logging__LogLevel__Default MARIA_HOSTED__Logging__LogLevel__Example.Category MARIA_HOSTED__Logging__File__RollingInterval MARIA_HOSTED__Logging__File__FileSizeLimitBytes MARIA_HOSTED__Logging__File__RollOnFileSizeLimit MARIA_HOSTED__Logging__File__RetainedFileCountLimit
External services translate these settings into their chosen logging framework at startup. They may optionally bind the framework-neutral MariaServiceLoggingOptions DTO from TPG.GDK.CommonCore.MariaService.Contracts, or implement the JSON/environment contract without a GDK reference.
Passing settings does not enforce an external service's logging behavior. A service must implement the policy for its own files. If its logging framework cannot honor an explicitly requested option, it should report this clearly during startup.
See Writing services for MariaServiceHoster for the wider child-service contract.
Child output in the hoster log
The hoster also forwards child console output into its own logger and keeps recent output for the monitor. Consequently, an event may appear both in a child's file and in the hoster's file.
The hoster's copy follows the hoster's minimum levels and retention, independently of the child's policy. Disabling a child's file sink does not disable its console stream or the hoster's capture of that stream.
The existing console parser recognizes GDK's console format. Arbitrary external output does not automatically provide equivalent level and category metadata, so console capture is not a substitute for implementing the logging policy inside the service.
See also
- MariaServiceHoster
- Writing services for MariaServiceHoster
- MariaServiceHoster README (repository access required)