@@ -9,6 +9,8 @@ namespace Splunk
9
9
/// </summary>
10
10
public static class LoggerFactoryExtensions
11
11
{
12
+ static readonly ILoggerFormatter DefaultLoggerFormatter = new BasicLoggerFormatter ( ) ;
13
+
12
14
/// <summary>
13
15
/// Add <see cref="T:Splunk.Providers.SplunkHECRawLoggerProvider"/> as provider to logger factory.
14
16
/// </summary>
@@ -17,6 +19,8 @@ public static class LoggerFactoryExtensions
17
19
/// <param name="formatter">Custom text formatter.</param>
18
20
public static ILoggerFactory AddHECRawSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
19
21
{
22
+ if ( formatter == null )
23
+ formatter = DefaultLoggerFormatter ;
20
24
loggerFactory . AddProvider ( new SplunkHECRawLoggerProvider ( configuration , formatter ) ) ;
21
25
return loggerFactory ;
22
26
}
@@ -29,6 +33,8 @@ public static ILoggerFactory AddHECRawSplunkLogger(this ILoggerFactory loggerFac
29
33
/// <param name="formatter">Custom text formatter.</param>
30
34
public static ILoggerFactory AddHECJsonSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
31
35
{
36
+ if ( formatter == null )
37
+ formatter = DefaultLoggerFormatter ;
32
38
loggerFactory . AddProvider ( new SplunkHECJsonLoggerProvider ( configuration , formatter ) ) ;
33
39
return loggerFactory ;
34
40
}
@@ -41,6 +47,8 @@ public static ILoggerFactory AddHECJsonSplunkLogger(this ILoggerFactory loggerFa
41
47
/// <param name="formatter">Custom text formatter.</param>
42
48
public static ILoggerFactory AddTcpSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
43
49
{
50
+ if ( formatter == null )
51
+ formatter = DefaultLoggerFormatter ;
44
52
loggerFactory . AddProvider ( new SplunkTcpLoggerProvider ( configuration , formatter ) ) ;
45
53
return loggerFactory ;
46
54
}
@@ -53,6 +61,8 @@ public static ILoggerFactory AddTcpSplunkLogger(this ILoggerFactory loggerFactor
53
61
/// <param name="formatter">Custom text formatter.</param>
54
62
public static ILoggerFactory AddUdpSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
55
63
{
64
+ if ( formatter == null )
65
+ formatter = DefaultLoggerFormatter ;
56
66
loggerFactory . AddProvider ( new SplunkUdpLoggerProvider ( configuration , formatter ) ) ;
57
67
return loggerFactory ;
58
68
}
0 commit comments