Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'LogManager' is an ambiguous reference between .LogManagers

I am getting the error message,"Error 19 'LogManager' is an ambiguous reference between 'Common.Logging.LogManager' and 'NLog.LogManager'".

In a C# 2008 application I am trying to add nlog open source logging tool to an application that is already using common.logging that was obtained from the following location: http://netcommon.sourceforge.net.

I have added a reference to the NLog file and I have added the Nlog to the using statement.

The problem is both tools use an object called 'LogManager'.

Thus can you tell me how to solve my problem so I can use both Logmanagers.

The following is my code listed below: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Text;
     using Common.Logging;
     using sample;
     using System.Configuration;
     using System.Xml.Linq;  
     using NLog;

namespace sample
{
  public class Etest
  {
    private static Logger logger = LogManager.GetCurrentClassLogger(); 
    private static ILog log = LogManager.GetCurrentClassLogger();
  }
}
like image 335
user1816979 Avatar asked Apr 27 '26 14:04

user1816979


1 Answers

You just need to make sure the calls are well qualified.

public class Etest
{
   private static Logger logger = NLog.LogManager.GetCurrentClassLogger(); 
   private static ILog log = Common.Logging.LogManager.GetCurrentClassLogger();
}
like image 80
Quintin Robinson Avatar answered Apr 29 '26 03:04

Quintin Robinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!