# Move away from \`Common.Logging\` library

**URL:** <https://discuss.hangfire.io/t/move-away-from-common-logging-library/378>\
**Category:** feature\
**Created:** [November 12, 2014, 1:26pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378 "2014-11-12T13:26:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![samdinesh86](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@samdinesh86](https://discuss.hangfire.io/u/samdinesh86)\
**Post date:** [November 12, 2014, 1:26pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/1 "2014-11-12T13:26:37Z")

</div>

Common.Logging.Core is deprecated and Common.Logging.Portable is added.Do we need to get a updated release with the new Dependency.

[https://www.nuget.org/packages/Common.Logging.Core/](https://www.nuget.org/packages/Common.Logging.Core/)

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [November 12, 2014, 1:59pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/2 "2014-11-12T13:59:27Z")

</div>

Argh, I can’t keep pace with `Common.Logging` changes. Such a common thing should be more stable. Thank you for keeping me in touch with new changes. I want to implement in 2.0 a simple logging interface to achieve the following goals:

- Support out of box popular logging frameworks without need to install additional packages (through relection).
- Users should be able to provide own implementation to hook with the current logger they use in project.

[This implementation](https://github.com/thinktecture/Thinktecture.IdentityServer.v3/tree/master/source/Core/Logging) can be considered as a proof of concept. What do you think?

---

<div class="post-metadata">

**Author:** ![Atreyu](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/atreyu/32/80_2.png) [@Atreyu](https://discuss.hangfire.io/u/Atreyu)\
**Post date:** [November 18, 2014, 10:56am UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/3 "2014-11-18T10:56:07Z")

</div>

Maybe it’s wise to also list the dependency to a maximum (or fixed) version of Common.Logging in NuGet.

See [http://docs.nuget.org/docs/Reference/Versioning](http://docs.nuget.org/docs/Reference/Versioning)

(For me the deployment to our test environment just broke because of this dependency, somehow it did not break on my development machine)

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [November 18, 2014, 11:00am UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/4 "2014-11-18T11:00:56Z")

</div>

Yep, but this will break current users. Do you have issues with previous version of the `Common.Logging` package?

---

<div class="post-metadata">

**Author:** ![geirsagberg](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/geirsagberg/32/17_2.png) [@geirsagberg](https://discuss.hangfire.io/u/geirsagberg)\
**Post date:** [November 20, 2014, 3:22pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/5 "2014-11-20T15:22:04Z")

</div>

My project also broke after updating Common.Logging, because it failed to find Common.Logging.Core (which is automatically removed when updating Common.Logging to 2.3.1). The workaround for me was to manually re-add Common.Logging.Core, but this feels wrong as it is deprecated. If Hangfire were updated to use the latest Common.Logging version, this would probably work as expected?

---

<div class="post-metadata">

**Author:** ![rikbosch](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@rikbosch](https://discuss.hangfire.io/u/rikbosch)\
**Post date:** [November 27, 2014, 3:30pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/6 "2014-11-27T15:30:32Z")

</div>

Please use LibLog and let the enduser specify the logging implementation.

LibLog is essentially a single cs file with multiple provider for Nlog, Log4Net, EntLib, Serilog and Loupe, and it is easy to create your custom logprovider

see:

> **[GitHub - damianh/LibLog: LibLog is a single file for you to either copy/paste...](https://github.com/damianh/LibLog)**
>
> LibLog is a single file for you to either copy/paste or install via nuget, into your library/framework/application to provide a logging abstraction. - GitHub - damianh/LibLog: LibLog is a single f...

edit:

> [@odinserj](#):
>
> This implementation can be considered as a proof of concept. What do you think?

that’s also liblog…

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [December 2, 2014, 3:02pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/7 "2014-12-02T15:02:50Z")

</div>

@rikbosch thank you, you saved my day!

This is a nice situation. Initial thought was to remove the need to upgrade current project dependencies to latest versions to use Hangfire. This decision works perfectly with `Newtonsoft.Json` package, but failed for `Common.Logging`. So, some action required for logging subsystem in Hangfire.

~~**Continue to use Common.Logging 2.2.0**~~

This seem as a reasonable solution unless some other package you use in your application depends on the latest version. In that case you will be **unable to use Hangfire** , so it is unacceptable to continue to use the old version.

~~**Upgrade Common.Logging to the latest version**~~

This step will require additional actions for Hangfire users as they need to update some other packages (for example, `Common.Logging.NLog`) in order to use the latest package version. The trouble is that other Hangfire packages (`Hangfire.PostgreSql`) depend on the old version of `Common.Logging` package, and _they should be re-released_.

After upgrading, we may have the same problems in future.

**Change Hangfire to use LibLog**

> A single file for you to either copy/paste or install via nuget, into your library/framework/application to enable dependency free logging. It contains transparent built-in support for NLog, Log4Net, EntLib Logging, Serilog and Loupe or allows the user to define a custom provider.  
> – [LibLog readme](https://github.com/damianh/LibLog/blob/master/ReadMe.md)

So, if you use one of the logging library mentioned above, you **don’t need to install anything else** , it just works. If you have other logging provider, all you need is to **implement two simple interfaces** :

```csharp
public interface ILogProvider
{
    ILog GetLogger(string name);
}

public interface ILog
{
    bool Log(LogLevel logLevel, Func<string> messageFunc);
    void Log<TException>(LogLevel logLevel, Func<string> messageFunc, TException exception) where TException : Exception;
}

```

This step will require to do the following things:

- Replace all references to `Common.Logging` API with the new logging provider in all Hangfire projects using Common.Logging.
- Implement interfaces described above for target projects if required, or at least remove the `LogManager.Adapter = /* ... */` line in the project.

Actions described above are similar to actions required to do after upgrading the `Common.Logging` version to the latest one, so it seems reasonable to me to perform the switch to the `LibLog` as soon as possible.

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [December 2, 2014, 3:07pm UTC](https://discuss.hangfire.io/t/move-away-from-common-logging-library/378/8 "2014-12-02T15:07:28Z")

</div>

> <https://github.com/HangfireIO/Hangfire/issues/265>
>
> Currently it is unable to use Hangfire in projects with packages that depend on Common.Logging \> 2.2.0. Unfortunately, we can't simply...
