@@ -9,6 +9,8 @@ namespace Splunk
99 /// </summary>
1010 public static class LoggerFactoryExtensions
1111 {
12+ static readonly ILoggerFormatter DefaultLoggerFormatter = new BasicLoggerFormatter ( ) ;
13+
1214 /// <summary>
1315 /// Add <see cref="T:Splunk.Providers.SplunkHECRawLoggerProvider"/> as provider to logger factory.
1416 /// </summary>
@@ -17,6 +19,8 @@ public static class LoggerFactoryExtensions
1719 /// <param name="formatter">Custom text formatter.</param>
1820 public static ILoggerFactory AddHECRawSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
1921 {
22+ if ( formatter == null )
23+ formatter = DefaultLoggerFormatter ;
2024 loggerFactory . AddProvider ( new SplunkHECRawLoggerProvider ( configuration , formatter ) ) ;
2125 return loggerFactory ;
2226 }
@@ -29,6 +33,8 @@ public static ILoggerFactory AddHECRawSplunkLogger(this ILoggerFactory loggerFac
2933 /// <param name="formatter">Custom text formatter.</param>
3034 public static ILoggerFactory AddHECJsonSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
3135 {
36+ if ( formatter == null )
37+ formatter = DefaultLoggerFormatter ;
3238 loggerFactory . AddProvider ( new SplunkHECJsonLoggerProvider ( configuration , formatter ) ) ;
3339 return loggerFactory ;
3440 }
@@ -41,6 +47,8 @@ public static ILoggerFactory AddHECJsonSplunkLogger(this ILoggerFactory loggerFa
4147 /// <param name="formatter">Custom text formatter.</param>
4248 public static ILoggerFactory AddTcpSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
4349 {
50+ if ( formatter == null )
51+ formatter = DefaultLoggerFormatter ;
4452 loggerFactory . AddProvider ( new SplunkTcpLoggerProvider ( configuration , formatter ) ) ;
4553 return loggerFactory ;
4654 }
@@ -53,6 +61,8 @@ public static ILoggerFactory AddTcpSplunkLogger(this ILoggerFactory loggerFactor
5361 /// <param name="formatter">Custom text formatter.</param>
5462 public static ILoggerFactory AddUdpSplunkLogger ( this ILoggerFactory loggerFactory , SplunkLoggerConfiguration configuration , ILoggerFormatter formatter = null )
5563 {
64+ if ( formatter == null )
65+ formatter = DefaultLoggerFormatter ;
5666 loggerFactory . AddProvider ( new SplunkUdpLoggerProvider ( configuration , formatter ) ) ;
5767 return loggerFactory ;
5868 }
0 commit comments