在这里,我们将给大家分享关于AzureAppInsights记录到.Net核心中的异常和跟踪的知识,让您更了解azureapplicationinsight的本质,同时也会涉及到如何更有效地.net–
在这里,我们将给大家分享关于Azure App Insights 记录到 .Net 核心中的异常和跟踪的知识,让您更了解azure application insight的本质,同时也会涉及到如何更有效地.net – 部署到Azure App Service时缺少Application Insights DLL、ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j、AKS pod 记录到 Azure 存储帐户、angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在的内容。
本文目录一览:- Azure App Insights 记录到 .Net 核心中的异常和跟踪(azure application insight)
- .net – 部署到Azure App Service时缺少Application Insights DLL
- ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j
- AKS pod 记录到 Azure 存储帐户
- angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在
Azure App Insights 记录到 .Net 核心中的异常和跟踪(azure application insight)
如何解决Azure App Insights 记录到 .Net 核心中的异常和跟踪
我正在寻找一种同时登录跟踪和异常的方法。如果我同时登录两者似乎更容易跟踪并且看起来每个人都喜欢它。除非有理由不这样做。
Logger.LogWarning(ex,"Audit Failed");
Logger.LogWarning("Audit Failed");
第一个记录异常,而第二个记录跟踪。我必须像这样将它添加到很多地方才能将其登录到两者中。 我错过的任何其他方式?
解决方法
如果我们想同时将日志发送到 Logger.LogWarning()
和 traces
,我们通常使用 2 个 exceptions
方法。
没有直接的方法可以做到这一点。您可以考虑编写一个 extension method,其中包含 2 个方法 Logger.LogWarning(ex,"Audit failed"); Logger.LogWarning("Audit failed");
。然后您只能调用此扩展方法一次并将日志发送到 traces
和 exceptions
。 Extension methods
如下所示:
public static class MyCustomLogger
{
//define an extension method.
public static void Custom_LogWarning(this ILogger logger,string msg)
{
//send this log into traces table
logger.LogWarning(msg);
//send this log into exceptions table
logger.LogWarning(new Exception(),msg);
}
}
然后你可以像下面这样使用这个扩展方法:
logger.Custom_LogWarning("it is a message from my custom log method...");
.net – 部署到Azure App Service时缺少Application Insights DLL
Could not load file or assembly ‘Microsoft.ApplicationInsights,
Version=1.2.0.5639,Culture=neutral,PublicKeyToken=31bf3856ad364e35’
or one of its dependencies. The system cannot find the file specified.
在WebAPI项目中,我清楚地看到Microsoft.ApplicationInsights引用,版本号是“1.2.0.5639”.
我使用VSO作为我的构建服务器(vNext不是基于XAML).我注意到在VSO构建日志中我收到了一条警告,说明DLL也丢失了.
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly “Microsoft.ApplicationInsights,Version=1.2.0.5639,
Culture=neutral,PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL”. Check to make sure the assembly exists on
disk. If this reference is required by your code,you may get
compilation errors.
构建服务器也清楚地显示了这个:
Primary reference “Microsoft.ApplicationInsights,
processorArchitecture=MSIL”.
有以下警告:
[warning]C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5):
Warning MSB3245: Could not resolve this reference. Could not locate
the assembly “Microsoft.ApplicationInsights,you may get
compilation errors.
我现在唯一能想到的可能是处理器架构是MSIL的问题吗?
更新:我还发布了3个Web作业(每个作业用户凭借自己的权限).目前我将webjobs包含在’webjobs-list.json’文件中,但是我将其删除以希望隔离问题.似乎2/3 webjobs能够找到DLL并将其复制到他们的
更新2:从JSON文件中删除WebJobs没有帮助.
更新3:好的,所以我设法让它工作.但是,仅当我从Visual Studio IDE部署时,而不是通过我在VSO上的自动构建. :*(我通过右键单击WebAPI项目然后查找Application Insights菜单项并使用’添加应用程序洞察向导’来使用Visual Studio上下文菜单.这很奇怪,因为App Insights在此项目中已经工作了很长时间.但是在我将它链接到我现有的应用洞察实例后,它在web.config中添加了一些条目.构建/部署让WebAPI重新开始工作.我甚至在WebJobs中添加回JSON文件.
解决方法
ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j
如何解决ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j
我正在Rails上执行此应用程序,页面加载正常,但在控制台中显示:
Started GET "/vendor/assets/stylesheets/bootstrap.min.css" for ::1 at 2020-08-17 09:09:51 -0500
Started GET "/vendor/assets/javascripts/bootstrap.min.js" for ::1 at 2020-08-17 09:09:51 -0500
ActionController::RoutingError (No route matches [GET]
"/vendor/assets/stylesheets/bootstrap.min.css"):
ActionController::RoutingError (No route matches [GET]
"/vendor/assets/javascripts/bootstrap.min.js"):
在我的供应商文件夹中,我同时拥有文件夹,javascript和样式表,并分别位于各自的bootsrtrap.min中。 即使在application.html.erb中,我也有以下内容:
<link href="vendor/assets/stylesheets/bootstrap.min.css" rel="stylesheet">
<%= csrf_Meta_tags %>
<%= stylesheet_link_tag ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
<%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>
</head>
<body>
<!-- Navigation -->
<nav>
<div>
<ahref="#">Instagram Clone</a>
<buttontype="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span></span>
</button>
<divid="navbarResponsive">
<ul>
<li>
<ahref="#">Home
<span>(current)</span>
</a>
</li>
<li>
<ahref="#">About</a>
</li>
<li>
<ahref="#">Services</a>
</li>
<li>
<ahref="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<div>
<div>
<div>
<%= yield %>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<!--<script src="vendor/jquery/jquery.slim.min.js"></script>-->
<script src="vendor/assets/javascripts/bootstrap.min.js"></script>
</body>
</html>