我正在使用Microsoft Application Insights我的Web应用程序.我使用Application Insights TraceListener NuGet包进行日志记录.这非常有效.
现在我想切换到NLog.我添加了Microsoft.ApplicationInsights.NLogTargetNuGet包并在我的NLog配置文件中添加了一个新的NLog目标:
<target name='ai' xsi:type='ApplicationInsights' />
Run Code Online (Sandbox Code Playgroud)
NLog引发异常:
Target cannot be found: 'ApplicationInsights'
Run Code Online (Sandbox Code Playgroud)
我也试过通过扩展添加程序集,如下所示:
<extensions>
<add assembly="Microsoft.ApplicationInsights.NLogTarget" />
</extensions>
Run Code Online (Sandbox Code Playgroud)
但它也没有用.
有什么建议?
我有以下配置,但没有跟踪到Application Insights(否则Application Insights可以正常用于其他日志记录,Azure诊断侦听器也在工作并捕获跟踪).难道我做错了什么?
<system.diagnostics>
<trace autoflush="true" indentsize="0">
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
</add>
<add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />
</listeners>
</trace>
</system.diagnostics>
Run Code Online (Sandbox Code Playgroud) system.diagnostics azure azure-diagnostics azure-application-insights
社区
我在将Application Insights连接到ASP WEB API Core时遇到了麻烦.按照标准手册,我仍无法在AppInsights帐户中找到任何记录.我使用了很多手册,但它们完全相同,并描述了如何为ASP Core(而不是API Core)配置App Insights.所以我想知道是否需要一些特殊配置(或nuget包或其他)来使AppInsights跟踪我的API服务请求?
一旦我无法使AppInsights开箱即用,我仍然可以创建TelemetryClient实例并手动发布数据,但在我的情况下这是不可取的.
重要提示:我正在使用VS 2017 RC,Web APi Core项目(csproj)
UPD
csproj文件内容:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild1-update1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild1-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-update1" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild1-update1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild1-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-update1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.1" />
<PackageReference …Run Code Online (Sandbox Code Playgroud) 我在 ASP.NET Core 3.1 中构建了一个简单的玩家跟踪 API 应用程序,该应用程序使用 Azure Cosmos DB 作为后端。
创建新玩家条目的 API 首先使用以下命令检查 Cosmos DB 中是否已存在给定分区键下具有相同 ID 的条目:
try
{
ItemResponse<Player> response = await this._playerContainer.ReadItemAsync<Player>(playerid, new PartitionKey(partitionkey));
return Conflict();
}
catch (CosmosException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
{
// There is some more logic happening here so I cannot directly just call CreateItemAsync()... and return the Conflict response that this might return.
ItemResponse<GameResult> response = await this._gameResultContainer.CreateItemAsync<GameResult>(gameresult, new PartitionKey(gameresult.PlayerId));
// ...
return Accepted();
}
Run Code Online (Sandbox Code Playgroud)
仅当此操作不返回任何内容时,我才会继续将创建请求放入后端工作队列中。否则,我将向 API 调用者返回 409-冲突。
实际插入发生在异步后端工作程序中。但我想直接返回 …
c# azure azure-application-insights asp.net-core azure-cosmosdb
我试图找出我的代码或方法有什么问题。我正在使用 Azure Functions (v3) 并使用 ILogger 接口来记录函数中的事件。这是我正在使用的示例代码:
[FunctionName("GetVersion")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("[TEST] this is informational");
log.LogDebug("[TEST] this is debug");
log.LogTrace("[TEST] this is trace");
return new OkResult();
}
Run Code Online (Sandbox Code Playgroud)
我的 Azure Functions 已启用 Application Insights,因此日志将写入跟踪表,我可以像这样查询它们:
traces
| order by timestamp
| where operation_Name == 'GetVersion'
| project timestamp,message,severityLevel
| limit 200
Run Code Online (Sandbox Code Playgroud)
但结果看起来像这样(列是时间戳、消息,最后一列是日志严重性级别):
我遇到的问题是:
预期行为是 App Insights 中的严重性与文档中的严重性级别相匹配。我在这里缺少什么?
PS 我的 host.json …
我们使用应用程序洞察来收集服务遥测数据,我们的服务是在 Service Fabric 集群上运行的 ASP NET Core。我们从我们的一项服务中观察到大量丢失的日志,并怀疑这是由于自适应采样造成的。
我有一些关于自适应采样的问题,以便更好地进行故障排除 -
任何帮助表示赞赏!
我在 Azure 上有一个 Java Web 应用程序,我在它的 Application Insights 中收到失败的请求。看起来有人每 5 分钟调用一次“http://myApp.azurewebsites.net/error”,但我没有这个接口,因此 Application Insights 中有很多失败的 404 请求。然后我在app中添加了这个接口,但是仍然有很多404代码的失败请求。我不知道这些请求,我不知道他们来自哪里,也不知道他们想做什么。我在应用程序中设置了错误的配置吗?
目前我正在将自定义日志消息记录到Azure表.
现在我需要根据日志类型自动触发发送电子邮件,还需要从日志消息中生成分析报告.
哪种服务更适合完成这项工作?Azure Application Insights或Azure Log Analytics?
我正在研究 Angular 应用程序,我想在我的 Angular SPA 中添加 Azure Application Insights。
我已经添加了所有必需的配置,并且一切正常。
Application Insights 将在 InstrumentationKey 的帮助下记录所有必需的详细信息,例如 PageView 和自定义事件。
但我有一个疑问,如果 ApplicationInsights InstrumentationKey 被盗会发生什么?InstrumentationKey 暴露于外部世界,任何人都可以看到它。
所以我的问题是,如果有人拿到这把钥匙有什么问题吗?如果 InstrumentationKey 被盗,什么是复制,我们如何避免它?
我有一个 .Net 5.0 Web 应用部署到 Azure 应用服务 Web 应用中。
今天,我想为我的应用服务 Web 应用启用 Application Insights 实例,但由于该Application Insights is not yet supported for .NET 5 Web Apps消息,目前看起来不可能。
我不想降级到 asp.net core 3.1。你有什么建议吗?
任何帮助都受到高度赞赏。
azure-application-insights ×10
azure ×7
asp.net-core ×2
c# ×2
logging ×2
.net-5 ×1
azure-devops ×1
nlog ×1