![](/img/trans.png)
[英]Logging to the Application Insights TRACE event type using ILogger in ASP.Net Core
ASP.NET 核心,targeting.net7.0 我正在使用 .NET Core ILogger機器將消息記錄到 Application Insights。 我想顯示應用程序調試信息,(我需要調試部署到 Azure 的應用程序)。 但我無法說服 Application Insights 不要 ...
[英]Logging to the Application Insights TRACE event type using ILogger in ASP.Net Core
ASP.NET 核心,targeting.net7.0 我正在使用 .NET Core ILogger機器將消息記錄到 Application Insights。 我想顯示應用程序調試信息,(我需要調試部署到 Azure 的應用程序)。 但我無法說服 Application Insights 不要 ...
[英]What is the difference between ApplicationInsights TrackEvent and ILogger LogInformation
如果我已經通過 ILogger (_logger.LogInformation) 記錄某些“事件”,那么添加(或更改為)telemetryClient.TrackEvent 是否有任何優勢? ...
[英]Get an ILogger instance for App Insights from ServiceCollection in a WebForms .NET Framework application
我們想要一個 ILogger 實例,以便它可以傳遞給其他庫。 我們在下面進行了嘗試,但 ILogger 實例未登錄到 Application Insights。 它成功登錄到事件查看器。 我們添加了必要的包,即 Microsoft.Extensions.Logging 和 Microsoft.Ext ...
[英]Can I change the category name given to ILogger<T> instances?
我有一個自定義ILogger實現以及一個ILoggerProvider ,我注意到Type.FullName中的categoryName參數似乎是ILoggerProvider.CreateLogger : 獲取類型的完全限定名稱,包括其命名空間但不包括其程序集。 然而,我的生產代碼被混淆了,雖然 ...
[英]Azure Function Logging Host vs. Function
我在多項目解決方案中設置了標准的 DI 日志記錄設置,但在 Function 日志記錄中,僅顯示了來自參數的 ILogger 實例,而不是來自從 Function 調用的服務的 ILogger<T> 日志。但是 ILogger<T> 日志確實如此顯示在主機日志中。 您能否從 ...
[英]Instantiate Singleton with ILogger before calling builder.Build()
我有一個 .NET 7 應用程序。 我目前有以下代碼: 我的SettingsService具有以下構造函數: 以上都很好用。 我現在想在調用var app = builder.Build();之前創建我的SettingsService . 我正在運行一些 HostedServices,並且只想根 ...
[英]What is the difference between AppInsights 'traces' and Log Analytics Workspace 'AppTraces'?
我們正在使用log.LogInformation(someString); 在 AppInsights 中,我們能夠查詢“traces”中的數據。 AppInsights 帳戶是使用 Log Analytics 工作區創建的。 在工作區中,我們看到“AppTraces”中的數據似乎相同。 這兩個 ...
[英]Pass ILogger<T> to Polly retry policy without HttpRequestMessage
當使用包裝在 Polly 的重試策略中並使用依賴注入注入 controller 的HttpClient實例進行 HTTP 調用時,我想將ILogger<T>從調用站點發送到重試策略的委托(例如onRetry ),所以記錄注冊更合適。 Polly 文檔解釋了如何通過將ILogger< ...
[英]What method is called during Ilogger conversion of structured logging arguments to string?
我有一個 object 我想傳遞給日志記錄(默認內置日志記錄到控制台,不使用庫)作為這樣的參數: 我所期望的是結果將是對command.ToString()的調用,但此調用的結果與實際的ToString()調用不同。 PS 有問題的BsonDocument是來自 MongoDB 驅動程序的 Bs ...
[英]How does MS default ILogger (Microsoft.Extensions.Logging.Logger) interpret args?
庫如何解釋 args 讓我有點困惑。 根據官方網站( https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-6.0&viewFallbackFrom=aspnetcore-2.2 ...
[英]C# iLogger when Log is called unable to write to file because file is in use
我的應用程序使用 iLogger,並且我已經實現了一個日志提供程序來寫入本地日志文件。 我遇到的問題是記錄了很多,特別是在調試模式下,我發現該文件正在使用中,無法打開 append 到它。 我正在尋找一些關於如何避免這個問題的建議。 我想過讓 Log function 添加到隊列中,並讓另一個線程啟 ...
[英]How to configure ILoggerFactory in .NET 6
在 .NET 5 Startup.cs class 中有 Configure 方法,它在ILoggerFactory接口中被注入。 見下文: 在 .NET 6 如何在var app = builder.Build();之后獲取 ILoggerFactory? 並調用它的AddFile()方法寫入日 ...
[英]ILogger with scope as global decorator
我正在考慮在我的類中使用BeginScope作為日志的全局裝飾器(因此特定 class 中的所有日志消息都將由特定文本裝飾)。 就像在 ctor 中啟動 scope 並僅在整個 class 也將被處置時處置它。 看起來它應該可以工作,但我沒有找到任何這樣使用的例子。 我看到的所有示例都是關於通過 ...
[英]Why are my logs not retrieved by application insights?
我有這個 azure function 應用程序,我在其中創建了一個啟動文件,這樣我就可以在 http 觸發器可用之前運行一次啟動程序。 在這次啟動中,我已將 applicationInsights 添加到我的日志記錄中,假設我的日志將包含在應用程序洞察力中。 當我調用 CheckDatabase ...
[英]C# Console App, pass multiple parameters to custom ILogger
搜索我沒有找到我正在尋找的答案。 我只會在此處放置代碼片段以幫助提出我的問題,如果沒有整個系統,提供所有代碼將無法執行。 我正在使用 C# 中的內置日志記錄到 Windows 事件查看器和/或控制台。 我還想寫入文件,但不想寫入第三方日志,所以我編寫了自己的簡單記錄器,將相同的數據記錄到文件中並正 ...
[英]How to associate request/response logs in .NET
很常見的場景: class MyServiceClient { ILogger<MyServiceClient> _logger; async Task Foo(Dto data) { _logger.LogDebug("Invoked API {Api ...
[英]How to register ILogger in Azure Function Dependency Injection and make it work for other related solution
我正在開發具有 HttpTrigger 和 TimeTrigger 類型的兩個函數的 .NET CORE 6 Azure 函數應用程序。 我有另一個解決方案,我也需要使用日志記錄,所以我在 Azure Function Startup 類的依賴容器中注冊日志記錄。 我有一個問題,當我注入服務時,例 ...
[英]Azure Function - ILogger is not logging?
我有一個天藍色的功能,它記錄信息沒有任何問題。 但是,我也有使用 DI 實現的業務邏輯,下面是實現的摘錄。 ServiceBase.cs 文件處理服務.cs 第 34 行和第 35 行不記錄任何內容 依賴注冊器.cs 我缺少什么以便FileProcessingServic ...
[英]How to get absolute path of running App using IHostBuilder
我為自定義記錄器創建了一個類庫,並使用IHostBuilder上的擴展方法將我的記錄器注冊到windows或web application 。 我想在Program.cs文件存在的目錄中創建"Log"文件夾(如果不存在)。 使用console application ,我可以使用相對路徑 Direc ...
[英]ILogger.BeginScope(IEnumerable<KeyValuePair<string, object>>) produces rubbish in ApplicationInsights
我想在我的日志消息中添加一些鍵值屬性。 我相信解決這個問題的方法是將IEnumerable<KeyValuePair<string, object>>傳遞給ILogger.BeginScope ,例如: 但是,在 ApplicationInsights 中,它顯示為垃圾 ...