Log4Net 和 .NET 4.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1866735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log4Net and .NET 4.0
提问by Bobbie
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?
有一段时间没有任何 log4net 版本了。这在 3.5 中没有出现任何问题,但是 .NET 4 呢?有没有人听说过关于支持第 4 版框架的版本发布的任何传言?
回答by Gryffe
"With .NET 4. Projects you can still use log4net. You will have to change the target platform to ".NET Framework 4" on the project..."
“使用 .NET 4。项目您仍然可以使用 log4net。您必须在项目上将目标平台更改为“.NET Framework 4”...”
Is correct. But you need to put the line
是正确的。但你需要把线
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
to the bottom of the configuration file (after the log4net setup):
到配置文件的底部(在 log4net 设置之后):
<?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>
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 1.2.10.0 测试您需要在 Assemblyinfo.cs 中放置以下行:[assembly: log4net.Config.XmlConfigurator(Watch = false)](我忘记了)
回答by krishna
With .NET 4. Projects you can still use log4net. You will have to change the target platform to ".NET Framework 4" on the project.
使用 .NET 4. 项目,您仍然可以使用 log4net。您必须将项目的目标平台更改为“.NET Framework 4”。
More details.... http://krishnabhargav.blogspot.com/2010/02/using-net-35-clr-20-dll-inside-visual.html
更多细节.... http://krishnabhargav.blogspot.com/2010/02/using-net-35-clr-20-dll-inside-visual.html
回答by weismat
回答by Lance Cleveland
Here are our notes about getting log4net working with VS2010 with C# and .Net 4.0. It basically follows the tseonet post but in a few simple steps. We also set security level to 1 instead of commenting AllowPartiallyTrustedCallers, but either option appears to work.
以下是我们关于在 VS2010 和 C# 和 .Net 4.0 中使用 log4net 的说明。它基本上遵循 tsenet 帖子,但只需几个简单的步骤。我们还将安全级别设置为 1,而不是注释 AllowPartiallyTrustedCallers,但是这两个选项似乎都有效。
Hope this is useful to someone: http://www.charlestonsw.com/configuring-log4net-with-vs2010-and-net-4-0/
希望这对某人有用:http: //www.charlestonsw.com/configuring-log4net-with-vs2010-and-net-4-0/
回答by Colin Pickard
There is a JIRA entry for .NET 4.0 and Client Profiles() but it is not slated for release in 1.2.11.
.NET 4.0 和 Client Profiles()有一个 JIRA 条目,但它不会在 1.2.11 中发布。
There is a related (unanswered) question with a comment that suggested you can simple run the 1.2.10 source through the VS2010 upgrade process.
有一个带有评论的相关(未回答)问题,建议您可以通过 VS2010 升级过程简单地运行 1.2.10 源代码。
回答by Abolfazl Rajabpour
i work with log4net in my asp.net Web Application and no problem.
我在我的 asp.net Web 应用程序中使用 log4net,没有问题。
i work by this tutorial: http://www.codeproject.com/KB/trace/Log4Net_with_ASP_NET.aspx
我按照本教程工作:http: //www.codeproject.com/KB/trace/Log4Net_with_ASP_NET.aspx
回答by Nachbars Lumpi
It seems that the current log4net trunk supports the .NET Framework 4.0. This support has just not yet been shipped with a release.
目前的 log4net 主干似乎支持 .NET Framework 4.0。此支持尚未随发行版一起提供。

