log4net的EventlogAppender不会为Asp.Net 2.0网页工作? [英] log4Net EventlogAppender does not work for Asp.Net 2.0 WebSite?

查看:111
本文介绍了log4net的EventlogAppender不会为Asp.Net 2.0网页工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置log4net的EventLogAppender为Asp.Net 2.0。然而,它不记录任何东西。我已经按照我的web.config。

I have configured log4Net EventLogAppender for Asp.Net 2.0. However it does not log anything. I have following in my Web.Config.

<log4net>
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <param name="LogName" value="Test Log" />
      <param name="ApplicationName" value="Test-Web" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <priority value="ERROR"/>
      <appender-ref ref="EventLogAppender"/>
    </root>
    <logger name="NHibernate">
      <level value="ERROR" />
      <appender-ref ref="EventLogAppender" />
    </logger>
  </log4net>

我已经有测试日志事件日志创建ASPNET用户对事件日志的注册表项的权限。我也有在Global.asax中的Application_Start log4net的配置。

I already have Test-Log Event Log created and AspNet user has permission on the Event Log registry entry. I also have log4Net configured in Global.asax Application_Start.

log4net.Config.XmlConfigurator.Configure();

更新:我打开了log4net的内部调试,发现下面的错误在跟踪

Update : I switched on the log4net internal debugging and found the following error in the trace.

log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [EventLogAppender] of type [log4net.Appender.EventLogAppender]. Reported error follows.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
   at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly)
   at System.Diagnostics.EventLog.SourceExists(String source, String machineName)
   at System.Diagnostics.EventLog.SourceExists(String source)
   at log4net.Appender.EventLogAppender.ActivateOptions()
   at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)

更新2 :如果我创建使用在C#基于控制台的应用程序,然后使用Web应用程序事件源(测试的Web),它最后的作品

Update 2 : It finally works if I create the Event Source (Test-Web) using a console based application in c# and then using the Web Application.

推荐答案

我不能告诉你到底是什么可能是错误的,但如果你去这里,你会看到我如何启用log4net的内部调试?一路下跌的底部。 log4net的不会抛出异常,如果事情是错误的,所以你必须为了获得log4net的信息,使内部调试。

I can't tell you exactly what might be wrong, but if you go here you will see "How do I enable log4net internal debugging?" way down at the bottom. Log4net will not throw exceptions if something is wrong, so you must enable internal debugging in order to get information from log4net.

http://logging.apache.org/log4net/release/faq.html

编辑:也看到,一个可能的解释与挂断使用EventLogAppender后直接quesiton

Also see the quesiton directly after that one that explains potential hangups with using the EventLogAppender.

这篇关于log4net的EventlogAppender不会为Asp.Net 2.0网页工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆