2013-02-12 5 views
9

NuGet 패키지를 사용하여 Common.Logging이 ASP.Net MVC 프로젝트에서 NLog2를 사용하도록 구성하려고합니다. 아래 URL에 제공된 정보를 기반으로 로거가 올바르게 구성되어 있지만 구성 오류가 계속 발생합니다.어떻게 Common.Logging을 성공적으로 구성 할 수 있습니까?

<configuration> 
    <configSections> 
     <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> 
     <sectionGroup name="common"> 
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" /> 
     </sectionGroup> 
    </configSections> 
    <common> 
     <logging> 
     <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20"> 
      <arg key="configType" value="INLINE" /> 
     </factoryAdapter> 
     </logging> 
    </common> 
    <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     <targets> 
     <target name="logfile" xsi:type="file" filename="e:\logfile.txt" layout="${date:format=yyyy/MM/dd HH:mm:ss} ${message}" /> 
     </targets> 
     <rules> 
     <logger name="*" minlevel="Trace" writeTo="logfile" /> 
     </rules> 
    </nlog> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> 
      <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> 
     </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 
는 지금까지 내가 말할 수있는 건,이 모든 것을 내가해야입니다

:

Common.Logging Configuration Instructions

NLog Configuration Tutorial

나는 지시에 따라 의 web.config에 다음을 추가했습니다 해야하지만 웹 프로젝트를 실행하려고하면 구성 오류가 발생합니다 ...

파서 오류 메시지 : 오류가 일반적인/로깅에 대한 구성 섹션 처리기 만들기 발생 : 유형 만들 수 없습니다 'Common.Logging.NLog.NLogLoggerFactoryAdapter을 Common.Logging.NLog20'

수있는 사람의 서비스 누락 또는 오류에 대한 제안?

답변

13

Common.Logging NuGet 패키지 (v2.0.0)에 의해 추가 된 기본 구성이 올바르지 않은 것으로 보입니다.

의 Web.config의 런타임 섹션은 다음과 같이 변경해야합니다 :

<dependentAssembly> 
    <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.0.0.0" /> 
    </dependentAssembly> 

참고 oldVersion 값을. 이것은 오류를 유발 한 것 같습니다 (적어도 위의 질문에서 설명한 시나리오에 기반 함).

관련 GitHub 문제 : Possible Issues with Common.Logging/Common.Logging.NLog20 NuGet packages도 참조하십시오.

1

는 끝

<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog2"> 

대신 2 대 고지 20

<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20"> 

로 사용하여 저했다.

+0

흠 나는 존재하지 않는다고 생각합니다 - 로깅 어셈블리의 오류가 켜져 있어야합니다 (실제로는 확실하지 않습니다) –

+0

이것은 실제로는 미신적 인 답변이 아닙니다 : 'Common.Logging.NLog'유형을 생성 할 수 없습니다. NLogLoggerFactoryAdapter, Common.Logging.NLog2 ' – PUG

관련 문제