To help you be aware of what’s happening with your application, Spark provides a logging service to allow you to log messages.

Under the hood, Spark uses the Serilog library.


Logging can be configured in your .env file.



Log channels control where your logs are written. There are currently 2 log channels..

  • file
  • console


Log levels control the minimum level of event that is logged to your channel.

For instance, if your log level is set to warning, only log messages with a warning level or higher will be logged. Debug and information logs would be ignored.

  • debug
  • information
  • warning
  • error
  • fatal

It is recommended to set your logs to warning in production to avoid noise in your logs.


The Spark logger is added to the DI container for you in AppServiceRegistration.AddAppServices().


To use the logger, inject Spark.Library.Logging.ILogger via dependency injection.

@* blazor example *@
@page "/"
@inject ILogger _logger
// class example
private ILogger _logger;

public MyService(ILogger logger)
    this._logger = logger;

Writing Log Messages

Once injected, you may call any of these methods to log a message for the corresponding level.


Stay up to date with Spark on Twitter or our Newsletter

Looking for .NET jobs? Check out Dotnet Jobs for weekly job postings.