Skip to content

Configuration ‐ Diagnostics Module ‐ Logging

Chris Mavrommatis edited this page Mar 27, 2025 · 2 revisions

Binacle.Net utilizes Serilog for its logging framework, providing structured and flexible logging. While Serilog offers many advanced features, Binacle.Net supports a predefined subset to ensure stability. It is recommended to use the provided configuration and avoid adding unsupported Serilog features.

⚙️ Default Logging Behavior

By default, Binacle.Net logs to both Console and File outputs, ensuring real-time visibility and historical retention.

📟 Console Logging

✅ Logs are output to the standard console, making it easy to monitor real-time activity.

📁 File Logging

✅ Logs are stored in app/data/logs/, following a daily logging format:

log-{date}.txt

⏳ Retention Policy:

  • Logs older than 7 days are automatically deleted to prevent excessive storage use.
  • No manual cleanup is required.

🛠️ 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/log-.txt",
          "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 using 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 information on this refer to the Configuration page.

However, this is not recommended unless you fully understand the implications, as incorrect configurations may impact stability and performance, or crash the application.

For advanced customization, refer to the official Serilog documentation:
📖 Configuration Basics
📖 Serilog Settings Configuration

Clone this wiki locally