2
votes

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 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: Loading from cache.

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: No matching token was found in the cache

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: An item was stored in the cache

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

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?

2
Have you looked at adding a filter? - jwdonahue
I'll try that if there's no more "direct" answer. I'm not sure that the messages I'm seeing in the console window are coming through Serilog, or whether they're getting there through some other mechanism. - Mark Olbert
Sorry, my C# foo is not strong after a year of writing no code. I think all of the Microsoft supplied .NET dll's will recognize and read a config file if laid down next to them and I know there's a standard way to adjust the diagnostic outputs via the XML therein. Don't know if that works with Serilog or not. - jwdonahue

2 Answers

6
votes

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 with assembly version '3.17.3.35304', file version '3.17.41219.2324' and informational version

Based on the log information, I tried to leverage ILSpy to decompile the package Microsoft.IdentityModel.Clients.ActiveDirectory and found the following code:

enter image description here

enter image description here

You could disable the trace logging under ADAL library via the following code:

LoggerCallbackHandler.UseDefaultLogging = false;

TEST:

enter image description here

0
votes

For version of 2.x of Microsoft.IdentityModel.Clients.ActiveDirectory, you'll need to call this:

using Microsoft.IdentityModel.Clients.ActiveDirectory;

AdalTrace.LegacyTraceSwitch.Level = TraceLevel.Error;

For version 3.x+ use Bruce_Chen's answer:

LoggerCallbackHandler.UseDefaultLogging = false;