BlabzX
BlabzX

Reputation: 143

Show logs in Hangfire Dashboard?

I've configured Log4net with Hangfire and it's logging correctly to the root directory of my project.

Is it possible to show the logs in the Dashboard UI under the specific job that was executed?

Upvotes: 8

Views: 11434

Answers (1)

Jawad
Jawad

Reputation: 11364

Hangfire.Console

This nuget package will allow you to add logs as you process the method. You can also show progress bar via the context. This is an extension to your existing Hangfire implementation. Be sure to add, 'using Hangfire.Console' in code where you are implementing the logs.

When you call the method, you basically provide null for the PerformContext and Hangfire fills it with the correct context when executing it. Based on this context and the Hangfire.Console extension, you can update the job log with Hangfire.Console's WriteLine(string) method.

Ref: Another thread that talks about how to use context.

Upvotes: 11

Related Questions