Logging that just works

Logging was a very difficult thing to set-up in previous versions of Hangfire. Even if we omit tricky versioning issues, you had to install a separate logging adapter for your current logging library, with guessing the right one first (i.e. Common.Logging.NLog or Common.Logging.NLog20).

Now, the logging just works. If your project already uses Elmah, NLog, Log4Net, EntLib Logging, Serilog or Loupe you are not required to do anything. Thanks to awesome LibLog library by Damian Hickey (@randompunter on Twitter), installed logging library will be used automatically through the reflection.

If your application uses other logging library or a custom one, just implement two simple interfaces:

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

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

And yes, Hangfire is no more have Common.Logging or Common.Logging.Core dependencies.

Debugging with Symbolsource

SymbolSource is a service which exposes PDB symbols so you can step through Hangfire code while debugging your application. There are a few things to configure before we can begin, see symbolsource.org for more information.

Within Visual Studio:

  1. Go to Tools → Options → Debugger → General
  2. Uncheck “Enable Just My Code (Managed only)”
  3. Uncheck “Enable .NET Framework source stepping”
  4. Check “Enable source server support”
  5. Uncheck “Require source files to exactly match the original version”
  6. Go to Tools → Options → Debugger → Symbols
  7. Select a folder for the local symbol/source cache
  8. Add symbol servers under “Symbol file (.pdb) locations”: http://srv.symbolsource.org/pdb/Public

To speed up startup of the debug session, you can specify only the Hangfire dlls to be loaded. Go to Tools → Options → Debugger → Symbols, select “Only specified modules” and enter Hangfire.*.dll

Now you can step into Hangfire code while debugging.

Changes

  • Added – Generation of NuGet symbol packages with *.pdb and source files.
  • Added – Allow to customize serialization settings of Json.NET (by @fpellet).
  • Added – Ability to configure ServerTimeout option.
  • Breaking – Use LibLog package instead of Common.Logging for logging.
  • ChangedHangfire.SqlServer is now merged with Dapper package.
  • ChangedDapper package updated to 1.38.
  • Changed – Use ILMerge instead of ILRepack.
  • Changed – Update Microsoft.Owin.Host.SystemWeb to the latest version.
  • Fixed – Dashboard not crash if a scheduling task is cancelled (by @fpellet).
  • Other – Use psake instead of MSBuild for project build automation.

Subscribe to monthly updates

Subscribe to receive monthly blog updates. Very low traffic, you are able to unsubscribe at any time.

Comments