All Projects → raisedapp → Hangfire.JobsLogger

raisedapp / Hangfire.JobsLogger

Licence: MIT License
A Hangfire extension to store a log during job execution.

Programming Languages

C#
18002 projects
HTML
75241 projects
ASP.NET
160 projects

Projects that are alternatives of or similar to Hangfire.JobsLogger

Serilog.exceptions
Log exception details and custom properties that are not output in Exception.ToString().
Stars: ✭ 282 (+1242.86%)
Mutual labels:  nuget, logging
Dotnetcore
.NET 5 Nuget Packages.
Stars: ✭ 146 (+595.24%)
Mutual labels:  nuget, logging
Log4net.elasticsearch
log4net appender to ElasticSearch
Stars: ✭ 202 (+861.9%)
Mutual labels:  nuget, logging
OpenSleigh
OpenSleigh is a Saga management library for .NET Core.
Stars: ✭ 198 (+842.86%)
Mutual labels:  nuget
NupkgWrench
Command line tool for reading and modifying nupkgs
Stars: ✭ 23 (+9.52%)
Mutual labels:  nuget
forge-checkmodels-createissues-revit
Design Check with Design Automation for Revit: Perform a basic design check on models uploaded to BIM 360 and log conflicts as Issues
Stars: ✭ 19 (-9.52%)
Mutual labels:  hangfire
logging
Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
Stars: ✭ 109 (+419.05%)
Mutual labels:  logging
cv4pve-api-dotnet
Proxmox VE Client API .Net C#
Stars: ✭ 25 (+19.05%)
Mutual labels:  nuget
logspout-gelf
Logspout with GELF adapter
Stars: ✭ 16 (-23.81%)
Mutual labels:  logging
tanka-graphql
GraphQL server and execution libraries
Stars: ✭ 57 (+171.43%)
Mutual labels:  nuget
H.NotifyIcon.WPF
NotifyIcon for .Net Core 3.1 and .Net 5 WPF.
Stars: ✭ 44 (+109.52%)
Mutual labels:  nuget
McSherry.SemanticVersioning
A semantic versioning library for .NET 5, Core, FX, and Standard with version range support.
Stars: ✭ 16 (-23.81%)
Mutual labels:  nuget
MojangSharp
A C# wrapper library for Mojang API (no longer actively maintained)
Stars: ✭ 38 (+80.95%)
Mutual labels:  nuget
King.Azure.Imaging
Image API & processing for Azure Web Apps
Stars: ✭ 20 (-4.76%)
Mutual labels:  nuget
thundra-agent-nodejs
Thundra Lambda Node.js Agent
Stars: ✭ 31 (+47.62%)
Mutual labels:  logging
LeagueReplayParser
C# library which can read some data from a .rofl file, and start a replay in the client. (no longer actively maintained)
Stars: ✭ 20 (-4.76%)
Mutual labels:  nuget
gxlog
A concise, functional, flexible and extensible logger for go.
Stars: ✭ 65 (+209.52%)
Mutual labels:  logging
PackageReferenceUpgrader
A VS2017 Extension that helps legacy apps migrate off of packages.config.
Stars: ✭ 27 (+28.57%)
Mutual labels:  nuget
nunit.testlogger
NUnit logger for vstest platform
Stars: ✭ 48 (+128.57%)
Mutual labels:  nuget
Pushover.NET
📣 .NET Wrapper for the Pushover API
Stars: ✭ 27 (+28.57%)
Mutual labels:  nuget

Hangfire.JobsLogger

NuGet Actions Status Master Actions Status Develop Official Site License MIT

Overview

A Hangfire extension to store a log during job execution

joblogshistory

Installation

Install a package from Nuget.

Install-Package Hangfire.JobsLogger

Usage

DotNetCore

For service side:

services.AddHangfire(config => config.UseSqlServerStorage(Configuration.GetConnectionString("HangfireConnection"))
                                                 .UseJobsLogger();

NetFramework

For startup side:

GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireConnection").UseJobsLogger();

Example

using Hangfire.JobsLogger;

RecurringJob.AddOrUpdate(() => taskExample.TaskMethod(null), Cron.Minutely);

//...

private readonly ILogger _log = ApplicationLogging.CreateLogger<TaskExample>();

public void TaskMethod(PerformContext context)
{
  var jobId = context.BackgroundJob.Id;

  foreach (int i in Enumerable.Range(1, 10)) 
  {
    context.LogTrace($"{i} - Trace Message.. {DateTime.UtcNow.Ticks}");
    context.LogDebug($"{i} - Debug Message.. {DateTime.UtcNow.Ticks}");
    context.LogInformation($"{i} - Information Message.. {DateTime.UtcNow.Ticks}");
    context.LogWarning($"{i} - Warning Message.. {DateTime.UtcNow.Ticks}");
    context.LogError($"{i} - Error Message.. {DateTime.UtcNow.Ticks}");
    context.LogCritical($"{i} - Critical Message.. {DateTime.UtcNow.Ticks}");

    //Traditional ILogger Usage
    _log.LogTrace(jobId: jobId, $"{i} - Trace Message.. {DateTime.UtcNow.Ticks}");
    _log.LogDebug(jobId: jobId, $"{i} - Debug Message.. {DateTime.UtcNow.Ticks}");
    _log.LogInformation(jobId: jobId, $"{i} - Information Message.. {DateTime.UtcNow.Ticks}");
    _log.LogWarning(jobId: jobId, $"{i} - Warning Message.. {DateTime.UtcNow.Ticks}");
    _log.LogError(jobId: jobId, $"{i} - Error Message.. {DateTime.UtcNow.Ticks}");
    _log.LogCritical(jobId: jobId, $"{i} - Critical Message.. {DateTime.UtcNow.Ticks}");
  }
}

Note Hangfire is responsible for injecting an instance of the PerformContext class.

The logs can be consulted in the detail of the logs on the enqueued state card: jobdetail

Options

In the UseJobsLogger method you can use an instance of the Hangfire.JobsLogger.JobsLoggerOptions class to specify some options of this plugin.

Below is a description of them:

Option Description Default Value
LogLevel Set the log level to be stored in hangfire Microsoft.Extensions.Logging.LogLevel.Trace
LogTraceColor Color that will be used to display log messages of this type System.Drawing.Color.LightGreen
LogDebugColor Color that will be used to display log messages of this type System.Drawing.Color.DarkGreen
LogInformationColor Color that will be used to display log messages of this type System.Drawing.Color.Blue
LogWarningColor Color that will be used to display log messages of this type System.Drawing.Color.DarkOrange
LogErrorColor Color that will be used to display log messages of this type System.Drawing.Color.Red
LogCriticalColor Color that will be used to display log messages of this type System.Drawing.Color.DarkRed

Credits

  • Brayan Mota
  • Lucas Ferreras

Thanks

This project would not have been possible, without the collaboration of the following projects:

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

paypal

License

This project is under MIT license. You can obtain the license copy here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].