Skip to content

AnderssonPeter/Hangfire.Console.Extensions

Repository files navigation

Hangfire.Console.Extensions

NuGet version

Features

  • Makes it easier to use Hangfire.Console with .net core dependency injection

Setup

In .NET Core's Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddHangfireConsoleExtensions();
}

Starting a job

To start a job you can use the IJobManager, it will automatically check if you are currently inside a job, if that is the case it will mark the started job as a Continuation.

Log

Instead of logging using the extension method on PerformContext you can now just use the ILogging and it will get logged to both normal logging facilities and Hangfire.Console.

Progressbar

To create a progress bar you can use IProgressBarFactory.

IJobCancellationToken

Just take the IJobCancellationToken as a constructor parameter to get a hold of the cancellation token.

Schedule jobs

Contains a extension method for AddOrUpdateManuallyTriggered if you have a job that should only be run manually.

Hangfire.Console.Extensions.Serilog

NuGet version

Usage with Serilog.Settings.Configuration

Add WithHangfireContext to Enrich and add Hangfire as a WriteTo target Example:

"Serilog": {
  "Enrich": [ "WithHangfireContext" ],
  "WriteTo": [
    {
      "Name": "Hangfire",
      "Args": {
        "restrictedToMinimumLevel": "Information"
      }
    }
  ]
}

About

Makes it easier to use Hangfire.Console with .net core dependency injection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages