Logging
Binacle.Net uses Serilog as its logging framework to provide structured, flexible, and efficient logging capabilities.
While Serilog offers many advanced features, Binacle.Net supports a predefined subset to ensure stability.
It is recommended to stick with the provided configuration and avoid using unsupported Serilog features.
βοΈ Default Logging Behavior
By default, Binacle.Net logs to both the Console and File outputs, ensuring real-time monitoring and historical log retention.
π Console Logging
β Logs are output to the console, allowing you to monitor real-time activity.
π File Logging
β
Logs are stored in the /app/data/logs/ directory. Logs are created daily with the following naming format:
{date}.ndjson
β³ Retention Policy:
- Logs older than 7 days are automatically deleted to save storage.
- No manual log cleanup is necessary.
π οΈ Configuration
The default Serilog configuration for Binacle.Net is as follows:
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Warning",
"Azure.Core": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console",
"outputTemplate": "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "data/logs/.ndjson",
"formatter": "Serilog.Formatting.Compact.RenderedCompactJsonFormatter, Serilog.Formatting.Compact",
"rollingInterval": "Day",
"retainedFileCountLimit": 7
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId",
"WithThreadId"
],
"Properties": {
"Application": "Binacle.Net"
}
}
}
You can modify the logging configuration through Production Overrides by creating a Serilog.Production.json file.
- π Location:
/app/Config_Files/DiagnosticsModule - π Full Path:
/app/Config_Files/DiagnosticsModule/Serilog.Production.json
For more details on overriding configurations, refer to the Configuration page.
Modifying the logging configuration is not recommended unless you fully understand its implications, as improper configurations can impact application stability or even cause crashes.
π‘ Sent over OpenTelemetry
With OpenTelemetry on, every log event
is also sent there, after the levels above have filtered it. The OTLP Logging switch turns this off for OTLP.
- The body is the finished message, with the values and the trace id as attributes. Before 3.2.0 it was the
template, such as
pack single_bin completed in {OperationDurationMs}ms. - Text values appear in quotes, as Serilog renders them:
Now listening on: "https://localhost:7194". The console shows them without quotes.
β±οΈ Per-Operation Line
Each fit or pack logs a line such as pack single_bin completed in 12.3ms. Since 3.2.0 it is logged at Debug, so
at the default level it does not show in the console, the log file or OpenTelemetry. The span and the
binacle.packing.operation.duration metric carry the same time. To see it again, add this override:
{
"Serilog": {
"MinimumLevel": {
"Override": {
"Binacle.Net.Telemetry": "Debug"
}
}
}
}
OperationDurationMs stays in milliseconds.
Advanced Customization
For advanced customization, refer to the official Serilog documentation: