log4net配置问题 [英] log4net configuration problem
本文介绍了log4net配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个单独的Log4Net.config文件。我添加了
I have a seperate Log4Net.config file. I added
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
到AssemblyInfo.cs
to AssemblyInfo.cs
当我运行应用程序使用调试模式,lognet是日志记录。当我将应用程序发布到IIS时,lognet不会记录任何内容。
When I run the application with debug mode, lognet is logging. When i publish the application to IIS, lognet is not logging anything.
我还有以下内容:
BasicConfigurator.Configure(); // in a method
private static readonly ILog _logger = LogManager.GetLogger(typeof(_Default)); // for the instance
这是什么原因?
检查AppPool用户帐户的方法如下:
Here's how to check the AppPool user account:
- 或者右键点击我的电脑,然后选择管理)
- 导航到服务和应用程序 / li>
- 在网站下找到您的网站,然后右键 - >属性
- 在虚拟目录选项卡上,记下应用程序池设置
- 取消此对话框,然后导航到IIS管理器中的应用程序池
- 右键单击上述应用程序池,
- 现在,我的建议是检查文件夹权限,您在哪里正在尝试写入日志,并确保应用程序池用户对该文件夹具有写入权限。
- Start->Run->"compmgmt.msc" (or right-click "My Computer" and select "Manage")
- Navigate to "Services and Applications"->"Internet Information Service (IIS) Manager"
- Find your site under "Web Sites" and right click->Properties
- On the Virtual Directory tab, make a note of the "Application pool" setting
- Cancel this dialog, and navigate to "Application pools" in the IIS manager
- Right click the app pool you noted above, select Properties, and select the Identity tab
- This shows the user account that is running the site.
- Now, my suggestion is to check the folder permissions where you are trying to write the log, and make sure the app pool user has write access to the folder.
如果这不是问题,我建议您开启 log4net内部调试:
If that's not the problem, I'd recommend turning on the log4net internal debugging:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
</configuration>
这篇关于log4net配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文