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

**URL:** <https://discuss.hangfire.io/t/is-there-a-way-to-use-performcontext-without-coupling-hangfire-dependencies-to-my-business-layer/6388>\
**Category:** question\
**Created:** [July 18, 2019, 3:12pm UTC](https://discuss.hangfire.io/t/is-there-a-way-to-use-performcontext-without-coupling-hangfire-dependencies-to-my-business-layer/6388 "2019-07-18T15:12:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcelo\_Ribeiro](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/marcelo_ribeiro/32/1657_2.png) [@Marcelo\_Ribeiro](https://discuss.hangfire.io/u/Marcelo_Ribeiro)\
**Post date:** [July 18, 2019, 3:12pm UTC](https://discuss.hangfire.io/t/is-there-a-way-to-use-performcontext-without-coupling-hangfire-dependencies-to-my-business-layer/6388/1 "2019-07-18T15:12:01Z")

</div>

Hello, people.

I’m using hangfire to run some background tasks (Recurring jobs) and I’m loading my jobs  
through reflection, so that I don’t have any framework dependencies in my code.  
Looking at hangfire extensions, I found Hangfire.Console that allows me to log to hangfire dashboard while the job is executing, but I can’t see a way to pass PerformContext to my jobs methods without coupling my code to Hangfire.Server, wich is not very cool, beucase what if I want to change the framework after some time? It will be very difficult.

I tried to create an abstract class wich extends PerformContext thinking that PerformContext would be injected through hierarchy, but it doesn’t work like that.

Is there a work around for this?

---

<div class="post-metadata">

**Author:** ![Steven\_Desrochers](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/steven_desrochers/32/1618_2.png) [@Steven\_Desrochers](https://discuss.hangfire.io/u/Steven_Desrochers)\
**Post date:** [July 19, 2019, 11:25am UTC](https://discuss.hangfire.io/t/is-there-a-way-to-use-performcontext-without-coupling-hangfire-dependencies-to-my-business-layer/6388/2 "2019-07-19T11:25:07Z")

</div>

This question seems awfully similar to [this one](http://hangfire.discourse.group/t/best-way-to-pass-logging-from-business-logic-up-to-hangfire-console/6354)

You could just have to create a Logger interface that you pass to your business layer. That way your business layer only knows that there’s an ILogger (regardless of framework)
