GVKun编程网logo

Azure App Insights 记录到 .Net 核心中的异常和跟踪(azure application insight)

2

在这里,我们将给大家分享关于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)

Azure App Insights 记录到 .Net 核心中的异常和跟踪(azure application insight)

如何解决Azure App Insights 记录到 .Net 核心中的异常和跟踪

我正在寻找一种同时登录跟踪和异常的方法。如果我同时登录两者似乎更容易跟踪并且看起来每个人都喜欢它。除非有理由不这样做。

  1. Logger.LogWarning(ex,"Audit Failed");
  2. Logger.LogWarning("Audit Failed");

第一个记录异常,而第二个记录跟踪。我必须像这样将它添加到很多地方才能将其登录到两者中。 我错过的任何其他方式?

解决方法

如果我们想同时将日志发送到 Logger.LogWarning()traces,我们通常使用 2 个 exceptions 方法。

没有直接的方法可以做到这一点。您可以考虑编写一个 extension method,其中包含 2 个方法 Logger.LogWarning(ex,"Audit failed"); Logger.LogWarning("Audit failed");。然后您只能调用此扩展方法一次并将日志发送到 tracesexceptionsExtension methods 如下所示:

  1. public static class MyCustomLogger
  2. {
  3. //define an extension method.
  4. public static void Custom_LogWarning(this ILogger logger,string msg)
  5. {
  6. //send this log into traces table
  7. logger.LogWarning(msg);
  8. //send this log into exceptions table
  9. logger.LogWarning(new Exception(),msg);
  10. }
  11. }

然后你可以像下面这样使用这个扩展方法:

  1. logger.Custom_LogWarning("it is a message from my custom log method...");

.net – 部署到Azure App Service时缺少Application Insights DLL

.net – 部署到Azure App Service时缺少Application Insights DLL

发布到Azure App Service后,我收到以下错误.

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文件.

解决方法

确保DLL的属性视图中copy Local设置为“True”

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

如何解决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>

在js和CSS这两个应用程序文件中,我都放置了“ require bootsrtrap.min”,即使该错误仍然出现在控制台中。 会是什么?

解决方法

RoR不使用目录作为文件夹结构指示。因为有资产装载者。您应该将5s或更少的css导入application.css中,并将js导入application.js中。并使用自己的助手添加捆绑文件:

1。用纱安装靴子

yarn add bootstrap @popperjs/core jquery

npm i bootstrap @popperjs/core jquery

栏位不超过5

2。在Assets Pipeline中导入文件

app / assets / stylesheets / application.css:

//...
require bootstrap/dist/css/bootstrap.min
//...

但是,如果需要,我建议使用SCSS并仅导入所需的样式。

app / assets / javascript / application.js:

//...
//= require jquery
//= require @popperjs/core
//= require bootstrap/dist/js/bootstrap.min
//...

3。在布局中导入资产

app / views / layout / application.html.erb:

<head>
...
  <%= stylesheet_link_tag ''application'',media: ''all'' %>
</head>
<body>
...
  <%= javascript_include_tag ''application'' %>
</body>

使用webpack滚动6

2。在application.scss和application.js中导入Bootstrap

app / javascript / stylesheets / application.scss:

//...
import ''bootstrap''
//...

app / javascript / packs / application.js:

import ''jquery''
import ''popper.js''
import ''bootstrap''
import ''../stylesheets/application''

3。在布局中导入捆绑包

<head>
...
  <%= stylesheet_pack_tag ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
  <%= javascript_pack_tag ''application'',''data-turbolinks-track'': ''reload'' %>
</head>

之后,您应该可以在所有应用程序中使用引导程序!

,

[解决方案]因此,在我的HTML(application.html.erb)内部,我有两个对js和css文件的调用:

<script src="assets/javascripts/bootstrap.min.js"></script>
  <%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>       
<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">
  <%= csrf_meta_tags %>
  <%= stylesheet_link_tag    ''application'',''data-turbolinks-track'': 
  ''reload'' %>

正如您在上面看到的那样,在使用javascript的情况下,我有一个使用脚本的调用,而另一个使用了的调用,两者都造成了问题,所以您只需要评论一个,我就对该脚本进行评论对于我的java文件和CSS文件,一个。 像这样:

  <!--<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">-->
    <!--<script src="assets/javascripts/bootstrap.min.js"></script>-->

对我来说,解决了这个问题,我真的尝试了所有事情,这就是解决方案哈哈。

AKS pod 记录到 Azure 存储帐户

AKS pod 记录到 Azure 存储帐户

如何解决AKS pod 记录到 Azure 存储帐户

我们一直在使用 Azure Kubernetes 服务 AKS 来运行应用程序。我们可以在标准输出中查看应用程序 (pod) 日志,也可以将其推送到 Azure Log Analytics 工作区。

但我们也想将这些 pod 日志推送到 Azure 存储帐户。我们怎样才能做到这一点?

感谢任何帮助

谢谢

angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在

angular – ng new hello错误:路径“/app/app.module.ts”不存在.路径“/app/app.module.ts”不存在

我在角度创建新项目时面临问题.
当我运行新的myapp命令时,我得到以下命令

新的你好

Error: Path "/app/app.module.ts" does not exist.
Path "/app/app.module.ts" does not exist.

谁能帮我吗???

解决方法

这是解决方案

Please make sure that your new folder have write permission

如果您使用的是ubuntu,请将以下命令运行到该文件夹

sudo chmod 644 -R foldername

然后运行新的appname

并检查您的节点版本

我们今天的关于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”不存在的相关信息,可以在本站进行搜索。

本文标签:

上一篇为什么我的 Widget 找不到我的 App 可以在 SwiftUI 中看到和找到的类?(为什么找不到widgetsmith)

下一篇如果应用未安装,iOS URL Scheme 会重定向到 App Store(未安装appsync)