title: How to configure a default target in NLog
body: <p>I am trying to convert existing logging library used by a bunch of apps to use NLog.  The existing logging code has no indirection, logging calls go straight from the caller to a webservice call.  The existing logging code is implemented as a static singleton.  I need to do this in such a way that existing applications that use this library do not need configuration or code changes when they pick up the changed logging library.  Later I can go update applications on an as needed basis, configuring a new logging target or changing the code to log to NLog directly.</p>
  
  <p>To do this, I was going to make the static logging code go through NLog.  Existing logging calls will be routed through NLog, and the existing webservice call will be wrapped in a custom NLog target.</p>
  
  <p>To make this work on legacy apps without changing them, I need to programmatically set the custom target as the default (when none are configured in a config file).  I'd like to do this without making config changes on the numerous existing applications, so I need to do this programmatically.</p>
  
  <p>The problem is... its not working.  Any thoughts on this approach?  Below is the code I tried to add to hook in the existing logger class to create the default target.</p>
  
  <p>I wouldn't mind going to log4net either.  Just looking at the APIs I chose NLog initially as the names made more sense to me.</p>
  
  <pre><code>public static class LegacyLogger
  {
      static LegacyLogger()
      {
          if (LogManager.Configuration == null
              || LogManager.Configuration.GetConfiguredNamedTargets().Count == 0)
          {
              if (LogManager.Configuration == null)
              {
                  LogManager.Configuration = new LoggingConfiguration();
              }
  
              //LogManager.Configuration.AddTarget("LegacyLogger", new NLog.Targets.DebuggerTarget());
              LogManager.Configuration.AddTarget("LegacyLogger", new LegacyLoggerTarget());
          }
  
          _logger = LogManager.GetCurrentClassLogger();
      }
  </code></pre>