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:

log-{date}.txt

โณ Retention Policy:

๐Ÿ› ๏ธ 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 through Production Overrides by creating a Serilog.Production.json file.

For more details on overriding configurations, refer to the Configuration Basics 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.


Advanced Customization

For advanced customization, refer to the official Serilog documentation: