Best way to pass logging from Business Logic up to Hangfire Console

Tags: #<Tag:0x00007f499aa14b00>


Hi All,
I have my code separated Data Layer, business logic Layer, and the Hang fire service consumes the BL layer.
I would rather not add HF references to my BL, but I want to add logging to the BL and see that logging in the HF console.

I have a couple of ideas but none seem to really work. Hoping someone has done this before and can save my self a few hours of tinkering and maybe someone can point me in the right direction.

Thanks in Advance!

Is there a way to use PerformContext without coupling hangfire dependencies to my business layer?

I can think of 2 ways of doing this:

  1. (best way in my opinion) Create a log interface in your BL and Implement that log interface inside the Hangfire service so that it can access Hangfire.Console.

  2. Seperate your method where you want to log, Then call each part from your hangfire service and place log in between.


Thanks for the direction. I went with number 1. it took me less than 15 mins to implement.

It really made the most sense. I put the interface for the logger in the same interface file as the back ground jobs Interfaces. minimal amount of code and worked perfectly.

Thanks again for the direction. Sometimes when you have been looking at a problem for and hour some times someone else option is a refreshing new concept :slight_smile: