我有一个单独的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
会是什么原因呢?
What would be the reason for this?
这可能是因为该程序池身份的用户没有权限写入日志文件/目录(假设你使用一个文件附加器)。
It could be that the AppPool identity user does not have permissions to write to the log file/directory (assuming you're using a file appender).
下面是如何检查程序池的用户帐户:
Here's how to check the AppPool user account:
在开始 - >运行 - >COMPMGMT.MSC(或右键单击我的电脑,选择管理) 在导航到服务和应用程序 - >Internet信息服务(IIS)管理器 找到您的网站的网站和右点击 - >属性 在虚拟目录选项卡,记下应用程序池的设置 取消此对话框,并定位在IIS管理器应用程序池 右键单击您在前面提到的应用程序池,选择属性,然后选择标识标签 这表明,在运行该网站的用户帐户。 现在,我的建议是检查您正在尝试写日志文件夹权限,并确保应用程序池的用户有写权限的文件夹。如果这不是问题,我建议你打开的 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>