log4net has a known issue of referencing a System.Web component which is not part of the .NET Framework 4 Client Profile and the VS2010 by default sets project target to be the lightweighted Client Profile. The solution is to change the target to .NET Framework 4:
Right click project -> properties -> Application. Change:
.NET Framework 4 Client Profile
to be:
.NET Framework 4
... and that should work, i.e. you can use log4net again...
来自:http://stackoverflow.com/questions/1767253/log4net-with-net-4-0
范例:
App.config
注意:configSections节点和startup节点的顺序,否则只见文件而无法输出日志
AssemblyInfo.cs中添加
.cs代码正常使用
解决log4net兼容性
本文介绍了解决log4net在.NET Framework 4 Client Profile下出现的兼容性问题的方法,通过更改目标框架为完整的.NET Framework 4即可。此外,还提供了配置示例,包括App.config文件设置及AssemblyInfo.cs中的配置。
171

被折叠的 条评论
为什么被折叠?



