Bonura.Hangfire.Dashboard.JobLogs
1.3.3
dotnet add package Bonura.Hangfire.Dashboard.JobLogs --version 1.3.3
NuGet\Install-Package Bonura.Hangfire.Dashboard.JobLogs -Version 1.3.3
<PackageReference Include="Bonura.Hangfire.Dashboard.JobLogs" Version="1.3.3" />
paket add Bonura.Hangfire.Dashboard.JobLogs --version 1.3.3
#r "nuget: Bonura.Hangfire.Dashboard.JobLogs, 1.3.3"
// Install Bonura.Hangfire.Dashboard.JobLogs as a Cake Addin #addin nuget:?package=Bonura.Hangfire.Dashboard.JobLogs&version=1.3.3 // Install Bonura.Hangfire.Dashboard.JobLogs as a Cake Tool #tool nuget:?package=Bonura.Hangfire.Dashboard.JobLogs&version=1.3.3
Hangfire.Dashboard.JobLogs
Show job logs on the dashboard.
The project takes advantage of the integration with NLog thanks to NLog.HangfireJobLogsTarget.
Note: the project is really simple but it is a good starting point (in my opinion).
Installation
Hangfire.Dashboard.JobLogs is available as a NuGet package. You can install it using the NuGet Package Console window:
PM> Install-Package Bonura.Hangfire.Dashboard.JobLogs
Configuration
NLog configuration with HangfireJobLogs
target and layout with ${hangfire-decorator}
(mandatory).
"NLog": {
"extensions": [
{
"assembly": "NLog.HangfireJobLogsTarget"
}
],
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Block"
},
"targets": {
"hangfire_dashboard": {
"layout": "${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=toString}${hangfire-decorator}",
"type": "HangfireJobLogs"
}
},
"rules": {
"hangfire": {
"logger": "Sample.Jobs.*",
"minLevel": "Info",
"writeTo": "hangfire_dashboard"
}
}
}
Services configuration:
// Add hangfire context services
builder.Services.AddHangfirePerformContextAccessor();
// Add Hangfire services.
builder.Services.AddHangfire((serviceProvider, config) =>
{
// Add filter to handle PerformContextAccessor
config.UsePerformContextAccessorFilter(serviceProvider);
// Add a storage
config.UseInMemoryStorage();
// Add dashboard jobLogs
config.UseDashboardJobLogs();
});
// Add the processing server as IHostedService
builder.Services.AddHangfireServer();
Job using ILogger
(Microsoft.Extensions.Logging):
public class SimpleJob
{
private ILogger<SimpleJob> _logger;
public SimpleJob(ILogger<SimpleJob> logger)
{
_logger = logger;
}
public async Task DoJobAsync()
{
_logger.LogInformation("Log message");
await Task.CompletedTask;
}
}
How it works
Basically, a log message produced by a hangfire job is captured by NLog NLog.HangfireJobLogsTarget
. Thanks to ${hangfire-decorator}
and PerformContextAccessor
log messages are sent to Hangfire storage.
Finally, log messages are shown on the detail page thanks to a simple JobDetailsRenderer
.
See sample project:
https://github.com/meriturva/Hangfire.Dashboard.JobLogs/tree/main/Sample
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Hangfire.Core (>= 1.8.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.