添加Log4Net.config配置文件
a)网上找一个Log4Net.config文件,复制粘贴进入自己的项目中。

找一个log4net.dll文件,并添加引用。
b)打开项目,点击Log4Net.config,将“复制到输出目录”选项改为“始终复制。”

c)打开AssemblyInfo.cs文件
添加语句:
|
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)] |

在需要的类中添加一下语句:
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
然后自定义方法,给日志文件中记录的内容。
1629

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



