azure-application-insights - C#-在哪里使用带有 azure 函数应用程序的 log4net 设置?
问题描述
我正在使用 azure 函数,为了将异常详细信息记录到 Azure 函数中的应用程序洞察力,我使用 TelemetryClient() 对象以及如下所示的检测密钥来记录消息
示例:
var telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = ConfigurationSettings.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"];
appInsights.TrackEvent(message);
所以,现在我想使用 Log4Net 通过 azure 函数将消息记录到应用程序洞察力。
在这里找到一些信息 Log4Net with Application Insights
为了使用具有适用洞察力的 log4net 日志,在 azure 函数中进行以下设置的位置在哪里?由于 azure function app 没有 web.config 文件。
我可以添加自定义配置文件并在下面设置并使用它吗?
<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>
解决方案
推荐阅读
- eclipse - Eclipse 站点地图管理器在哪里
- javascript - 如何将对象放入对象内部
- r - DiagrammR中填充颜色的Alpha
- c# - 可能的 System.InvalidCastException 将枚举转换为 int?
- python - 在 Django 视图中计算 i+1 或 i-1
- javascript - 我可以在非 SPA 项目上使用 Axios 吗?
- ruby - 如何从小写字符串数组中返回随机的大写和小写字符串
- angular - 如何在构造函数Angular中传递对象?
- python - 如果条件为 Pandas 数据框的减法
- docker - 在 GitLabCI 管道中构建 docker 镜像