-
Notifications
You must be signed in to change notification settings - Fork 9.8k
/
AzureBlobLoggerOptions.cs
45 lines (37 loc) · 1.33 KB
/
AzureBlobLoggerOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.AspNetCore.Shared;
namespace Microsoft.Extensions.Logging.AzureAppServices;
/// <summary>
/// Options for Azure diagnostics blob logging.
/// </summary>
public class AzureBlobLoggerOptions : BatchingLoggerOptions
{
private string _blobName = "applicationLog.txt";
/// <summary>
/// Gets or sets the last section of log blob name.
/// Defaults to <c>"applicationLog.txt"</c>.
/// </summary>
public string BlobName
{
get { return _blobName; }
set
{
ArgumentThrowHelper.ThrowIfNullOrEmpty(value);
_blobName = value;
}
}
/// <summary>
/// Gets or sets the format of the file name.
/// Defaults to "AppName/Year/Month/Day/Hour/Identifier".
/// </summary>
public Func<AzureBlobLoggerContext, string> FileNameFormat { get; set; } = context =>
{
var timestamp = context.Timestamp;
return $"{context.AppName}/{timestamp.Year}/{timestamp.Month:00}/{timestamp.Day:00}/{timestamp.Hour:00}/{context.Identifier}";
};
internal string ContainerUrl { get; set; }
internal string ApplicationName { get; set; }
internal string ApplicationInstanceId { get; set; }
}