log4net的和.NET 4.0 [英] Log4Net and .NET 4.0

查看:162
本文介绍了log4net的和.NET 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前还没有任何log4net的发布有一段时间了。这并没有presented任何问题,3.5,但对于.NET 4?有没有人听到任何有关传言的释放来支持版本4框架出来时?

There have not been any log4net release for some time. This has not presented any problems with 3.5, but what about .NET 4? Has anyone heard any rumblings about a release to support the version 4 framework when it comes out?

推荐答案

在.NET 4项目,你仍然可以使用log4net的,你将不得不改变目标平台,以.NET框架4的项目.. 。

"With .NET 4. Projects you can still use log4net. You will have to change the target platform to ".NET Framework 4" on the project..."

是正确的。但是,你需要把行

Is correct. But you need to put the line

<startup>
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

配置文件的底部(后log4net的设置):

to the bottom of the configuration file (after the log4net setup):

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="logfile.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date: %-5level – %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="DEBUG" />
      <appender-ref ref="FileAppender" />
    </root>
  </log4net>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

测试与log4net的1.2.10.0 你需要把该行:     [总成:log4net.Config.XmlConfigurator(表= FALSE)] 在AssemblyInfo.cs中(我忘了)

Tested with log4net 1.2.10.0 You need to put the line: [assembly: log4net.Config.XmlConfigurator(Watch = false)] in Assemblyinfo.cs (I forgot that)

这篇关于log4net的和.NET 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆