|
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:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
</targets>
<rules>
</rules>
</nlog>
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();
}
}
|
|
|
|
|
You have to preface the LogManager object with the namespace that it's coming from, either NLog.LogManager or Common.Logging.LogManager.
You can shorten the namespace for the Common one by changing the using line for it to something like:
using CL = Common.Logging;
Then you can use CL.LogManager .
|
|
|
|