Skip to content

Commit d334555

Browse files
authored
Adding logging for Storage operations (#7471)
1 parent 3cffa21 commit d334555

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/WebJobs.Script/ScriptHostBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,16 +455,19 @@ private static IDistributedLockManager GetBlobLockManager(IServiceProvider provi
455455
{
456456
var azureStorageProvider = provider.GetRequiredService<IAzureStorageProvider>();
457457
var loggerFactory = provider.GetRequiredService<ILoggerFactory>();
458+
var logger = loggerFactory.CreateLogger<IDistributedLockManager>();
458459
try
459460
{
460461
var container = azureStorageProvider.GetBlobContainerClient();
462+
logger.LogDebug("Using BlobLeaseDistributedLockManager in Functions Host.");
461463
return new BlobLeaseDistributedLockManager(loggerFactory, azureStorageProvider);
462464
}
463465
catch (InvalidOperationException)
464466
{
465467
// If there is an error getting the container client,
466468
// register an InMemoryDistributedLockManager.
467469
// This signals a failed validation in connection configuration (i.e. could not create the storage client).
470+
logger.LogDebug("Using InMemoryDistributedLockManager in Functions Host.");
468471
return new InMemoryDistributedLockManager();
469472
}
470473
}

src/WebJobs.Script/StorageProvider/BlobServiceClientProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Microsoft.Azure.WebJobs.Script.StorageProvider
1616
/// </summary>
1717
internal class BlobServiceClientProvider : StorageClientProvider<BlobServiceClient, BlobClientOptions>
1818
{
19-
public BlobServiceClientProvider(IConfiguration configuration, AzureComponentFactory componentFactory, AzureEventSourceLogForwarder logForwarder, ILogger<BlobServiceClient> logger)
19+
public BlobServiceClientProvider(IConfiguration configuration, AzureComponentFactory componentFactory, AzureEventSourceLogForwarder logForwarder, ILogger<BlobServiceClientProvider> logger)
2020
: base(configuration, componentFactory, logForwarder, logger) { }
2121

2222
/// <inheritdoc/>

src/WebJobs.Script/StorageProvider/StorageClientProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal abstract class StorageClientProvider<TClient, TClientOptions> where TCl
3232
/// <param name="configuration">The configuration to use when creating Client-specific objects. <see cref="IConfiguration"/></param>
3333
/// <param name="componentFactory">The Azure factory responsible for creating clients. <see cref="AzureComponentFactory"/></param>
3434
/// <param name="logForwarder">Log forwarder that forwards events to ILogger. <see cref="AzureEventSourceLogForwarder"/></param>
35-
public StorageClientProvider(IConfiguration configuration, AzureComponentFactory componentFactory, AzureEventSourceLogForwarder logForwarder, ILogger<TClient> logger)
35+
public StorageClientProvider(IConfiguration configuration, AzureComponentFactory componentFactory, AzureEventSourceLogForwarder logForwarder, ILogger<StorageClientProvider<TClient, TClientOptions>> logger)
3636
{
3737
_configuration = configuration;
3838
_componentFactory = componentFactory;
@@ -65,7 +65,7 @@ public virtual bool TryGet(string name, out TClient client)
6565
catch (Exception ex)
6666
{
6767
client = default(TClient);
68-
_logger.LogError(ex, "Could not create Storage Client");
68+
_logger.LogDebug("Could not create Storage Client. Exception: {0}", ex.ToString());
6969
return false;
7070
}
7171
}
@@ -86,7 +86,7 @@ public virtual bool TryGetFromConnectionString(string connectionString, out TCli
8686
catch (Exception ex)
8787
{
8888
client = default(TClient);
89-
_logger.LogError(ex, "Could not create Storage Client from a connection string.");
89+
_logger.LogDebug("Could not create Storage Client from a connection string. Exception: {0}", ex.ToString());
9090
return false;
9191
}
9292
}
@@ -190,7 +190,7 @@ protected virtual bool TryGetServiceUri(IConfiguration configuration, out Uri se
190190
}
191191
catch (Exception ex)
192192
{
193-
_logger.LogError(ex, "Could not parse serviceUri from the configuration.");
193+
_logger.LogDebug("Could not parse serviceUri from the configuration. Exception: {0}", ex.ToString());
194194
}
195195

196196
serviceUri = default(Uri);

0 commit comments

Comments
 (0)