通过Azure KeyVault禁止控制台日志记录 [英] Suppressing Console Logging by Azure KeyVault
问题描述
我正在Net Core 2控制台应用程序中使用C#访问Azure密钥库.每当运行该应用程序时,当我从库中检索秘密时,控制台窗口就会显示如下消息:
I'm accessing an Azure key vault, using C#, in a Net Core 2 console app. Whenever the app runs, the console window gets hit with messages like this when I retrieve a secret from the vault:
2017-12-26T18:03:49.8610049Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- AcquireTokenHandlerBase.cs:带有程序集版本的ADAL PCL.CoreCLR '3.17.3.35304',文件版本'3.17.41219.2324'和参考 版本'b6afaeae7cff965e66649e0ee7e8c29071d5a7e6'正在运行... 2017-12-26T18:03:49.8621855Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- AcquireTokenHandlerBase.cs:===令牌获取已开始: 权限: https://login.windows.net/[...]/ 资源: https://vault.azure.net 客户编号:[...] CacheType:null 身份验证目标:客户端
2017-12-26T18:03:49.8610049Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - AcquireTokenHandlerBase.cs: ADAL PCL.CoreCLR with assembly version '3.17.3.35304', file version '3.17.41219.2324' and informational version 'b6afaeae7cff965e66649e0ee7e8c29071d5a7e6' is running... 2017-12-26T18:03:49.8621855Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - AcquireTokenHandlerBase.cs: === Token Acquisition started: Authority: https://login.windows.net/[...]/ Resource: https://vault.azure.net ClientId: [...] CacheType: null Authentication Target: Client
2017-12-26T18:03:49.8981211Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- AcquireTokenHandlerBase.cs:从缓存加载.
2017-12-26T18:03:49.8981211Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - AcquireTokenHandlerBase.cs: Loading from cache.
2017-12-26T18:03:49.9010018Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- TokenCache.cs:在缓存中查找令牌...
2017-12-26T18:03:49.9010018Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - TokenCache.cs: Looking up cache for a token...
2017-12-26T18:03:49.9060990Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- TokenCache.cs:在缓存中找不到匹配的令牌
2017-12-26T18:03:49.9060990Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - TokenCache.cs: No matching token was found in the cache
2017-12-26T18:03:50.2185881Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- TokenCache.cs:将令牌存储在缓存中...
2017-12-26T18:03:50.2185881Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - TokenCache.cs: Storing token in the cache...
2017-12-26T18:03:50.2211369Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- TokenCache.cs:项目已存储在缓存中
2017-12-26T18:03:50.2211369Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - TokenCache.cs: An item was stored in the cache
2017-12-26T18:03:50.2351165Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- AcquireTokenHandlerBase.cs:===令牌获取完成 成功地.访问令牌已重新调整:
2017-12-26T18:03:50.2351165Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - AcquireTokenHandlerBase.cs: === Token Acquisition finished successfully. An access token was retuned:
Access Token Hash: [...]
Expiration Time: 12/26/2017 7:03:49 PM +00:00
User Hash: null
我不记得要在代码中做任何事情来设置密钥库访问的任何类型的日志记录.但是,我已经在整个应用程序中配置了Serilog的ILogger,所以也许以某种方式被采用了.
I don't recall doing anything in my code to set up any kind of logging for the key vault access. However, I have configured Serilog's ILogger throughout the app, so maybe that's being picked up, somehow.
如何禁止显示这些消息?
How do I suppress these messages from being displayed?
推荐答案
According to your description, I checked the source code of Microsoft.Azure.KeyVault, but did not find any relevant logging.
2017-12-26T18:03:49.8610049Z:29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56- AcquireTokenHandlerBase .cs: ADAL PCL.CoreCLR的程序集版本为' 3.17.3.35304",文件版本"3.17.41219.2324"和参考版本
2017-12-26T18:03:49.8610049Z: 29c98a86-9e1d-4a5d-86d6-daf8f2cfdc56 - AcquireTokenHandlerBase.cs: ADAL PCL.CoreCLR with assembly version '3.17.3.35304', file version '3.17.41219.2324' and informational version
根据日志信息,我尝试利用 ILSpy 来反编译软件包
Based on the log information, I tried to leverage ILSpy to decompile the package Microsoft.IdentityModel.Clients.ActiveDirectory and found the following code:
您可以通过以下代码在ADAL库下禁用跟踪日志记录:
You could disable the trace logging under ADAL library via the following code:
LoggerCallbackHandler.UseDefaultLogging = false;
测试:
这篇关于通过Azure KeyVault禁止控制台日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!