1

I like NLog due to multiple reasons described in https://robertmccarter.com/switching-to-nlog and

log4net vs. Nlog

However I consider   https://github.com/ServiceStack/ServiceStack and https://nuget.org/packages/ServiceStack.Logging.NLog to keep generic interface and ability to switch to other provider in a future.

Is anyone aware about any disadvantages/limitations of using ServiceStack.Logging.NLog  instead of direct NLog calls?

Will it cause any essential performance degradation?

Is any functionality that available when called NLog loggers directly, but not supported by  ServiceStack?

Community
  • 1
  • 1
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170

2 Answers2

5

I've compared   ServiceStack ILog  , Common.Logging/ILog   and   NLog/Logger.cs and found that NLog has bigger number of overloads, that make it more type-safe. Also NLog has logic to  not process formatting if the logging for the particular record is disabled. 

Based on this I decided that using generic logging interface is YAGNI. If I would write library to be used in multiple applications with potentially different logging library used,  ServiceStack is a way to go.

However in application development with no immediate need to support more than one logging framework, it is more efficient to call Nlog directly. If in a future it would be decided to switch to other provider, global replace changes to call  ServiceStack or directly new provider should be relatively easy.

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
3

The quick answer is - you should be just fine using the ServiceStack NLog implementation via their generic logging interface. It looks like it'll give you just about everything you need.

You can check out the ServiceStack NLog implementation code @ https://github.com/ServiceStack/ServiceStack.Logging/tree/master/src/ServiceStack.Logging.NLog

I'm assuming that you can still configure NLog via the NLog.config file, and that the default NLogFactory will pick it up - so this will still allow you to do things like logger-specific routing, multiple targets, etc.

Performance degradation won't be an issue (unless you verbose log every tiny thing in production, but that's on you, not the framework).

Without going through the NLog implementation in total detail, I can't say that you'll have every bit of functionality via ServiceStack NLog - but as far as what you need to log your code, you'll be good to go.

Mike Pugh
  • 6,787
  • 2
  • 27
  • 25