具有应用程序见解的Log4Net [英] Log4Net with Application Insights

查看:72
本文介绍了具有应用程序见解的Log4Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的azure asp.net网站配置为将log4net跟踪发送到Azure Application Insights.我可以在我的azure控制台中查看页面视图等,因此我知道它工作正常.当配置了文件处理程序时,我还可以看到log4net跟踪,但是当配置log4net以使用应用程序见解处理程序时,我看不到任何log4net条目出现在应用程序见解仪表板中,在构建或运行时都没有错误或警告-只是仪表板中无结果.我已经查看了Fiddler中的网络流量,并且可以看到将页面浏览数据等发送给应用程序见解,但没有看到log4net跟踪流量,因此我怀疑这是配置问题.

I am trying to configure my azure asp.net website to send log4net traces to Azure Application Insights. I can see in my azure console page views etc, hence I know that is working fine. I can also see log4net traces, when configured with a file handler, but when configuring log4net to use the application insights handler I don't see any log4net entries appear in the application insight dashboard, no errors or warnings at build or run time - just no results in the dashboard. I have looked at the network traffic in Fiddler, and I can see the pageview data etc being sent to application insights, but not the log4net trace traffic hence I suspect this is a configuration issue.

另外,我在主项目中尝试了TelemetryClient(),并且在仪表板中成功看到了tracetraffic.但是,这不适合我的用例,因为TelemetryClient似乎还不支持非asp.net dll(即我的业务和数据逻辑位于单独的dll中).

Separately I have tried the TelemetryClient() in my main project, and I see the tracetraffic sucesfully in the dashboard. However, this does not fit my use case as TelemetryClient does not seem to support non asp.net dll's as yet (i.e. my business and data logic which are in separate dll's).

有人提供任何见识或建议吗?

Anyone offer any insight or advice?

我已经为Microsoft.ApplicationInsights.Log4NetAppender.dll安装了nuget软件包,并且正在使用Microsoft.ApplicationInsights.0.13.2-build00132

I have installed the nuget package for Microsoft.ApplicationInsights.Log4NetAppender.dll and I am using Microsoft.ApplicationInsights.0.13.2-build00132

根据 https://blog.ehn.nu/2014/11/using-log4net-for-application-insights/

<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <log4net>
    <root>
      <level value="ALL"/>
      <appender-ref ref="aiAppender"/>
    </root>
    <appender name="aiAppender" type="Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppender, Microsoft.ApplicationInsights.Log4NetAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%message%newline"/>
      </layout>
    </appender>
  </log4net>
<configuration>

推荐答案

尝试安装我已按照是由其他人创建的,并且在上述问题上也存在相同的问题.但随后执行了一些步骤,该步骤在应用程序见解"中文档,并发现这些用户指定为log4net附加程序安装PreRelease软件包.完成工作后:)

I had created a canonical ASP.NET MVC example following the steps created by someone else and had the same problem above. But then followed some steps written in the Application Insights documentation and discovered that those specified installing the PreRelease package for the log4net appender. Having done that it workd :)

这篇关于具有应用程序见解的Log4Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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