You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Serilog.Extensions.Hosting/SerilogLoggingBuilderExtensions.cs
+180-2Lines changed: 180 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
-
usingMicrosoft.Extensions.DependencyInjection;
1
+
usingMicrosoft.Extensions.Configuration;
2
+
usingMicrosoft.Extensions.DependencyInjection;
3
+
usingSerilog;
4
+
usingSerilog.Extensions.Hosting;
2
5
usingSerilog.Extensions.Logging;
3
6
usingSystem;
4
7
usingstaticSerilog.SerilogHostBuilderExtensions;
@@ -21,7 +24,7 @@ public static class SerilogLoggingBuilderExtensions
21
24
/// <param name="providers">A <see cref="LoggerProviderCollection"/> registered in the Serilog pipeline using the
22
25
/// <c>WriteTo.Providers()</c> configuration method, enabling other <see cref="Microsoft.Extensions.Logging.ILoggerProvider"/>s to receive events. By
23
26
/// default, only Serilog sinks will receive events.</param>
24
-
/// <returns>The host builder.</returns>
27
+
/// <returns>The logging builder.</returns>
25
28
publicstaticILoggingBuilderAddSerilog(
26
29
thisILoggingBuilderbuilder,
27
30
Serilog.ILoggerlogger=null,
@@ -61,5 +64,180 @@ public static ILoggingBuilder AddSerilog(
61
64
62
65
returnbuilder;
63
66
}
67
+
68
+
/// <summary>Sets Serilog as the logging provider.</summary>
69
+
/// <remarks>
70
+
/// A <see cref="ILoggingBuilder"/> is supplied so that configuration and hosting information can be used.
71
+
/// The logger will be shut down when application services are disposed.
72
+
/// </remarks>
73
+
/// <param name="builder">The logging builder to configure.</param>
74
+
/// <param name="configureLogger">The delegate for configuring the <see cref="Serilog.LoggerConfiguration" /> that will be used to construct a <see cref="Serilog.Core.Logger" />.</param>
75
+
/// <param name="preserveStaticLogger">Indicates whether to preserve the value of <see cref="Serilog.Log.Logger"/>.</param>
76
+
/// <param name="writeToProviders">By default, Serilog does not write events to <see cref="ILoggerProvider"/>s registered through
77
+
/// the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify
78
+
/// <c>true</c> to write events to all providers.</param>
79
+
/// <remarks>If the static <see cref="Log.Logger"/> is a bootstrap logger (see
80
+
/// <c>LoggerConfigurationExtensions.CreateBootstrapLogger()</c>), and <paramref name="preserveStaticLogger"/> is
81
+
/// not specified, the the bootstrap logger will be reconfigured through the supplied delegate, rather than being
/// <summary>Sets Serilog as the logging provider.</summary>
181
+
/// <remarks>
182
+
/// A <see cref="ILoggingBuilder"/> is supplied so that configuration and hosting information can be used.
183
+
/// The logger will be shut down when application services are disposed.
184
+
/// </remarks>
185
+
/// <param name="builder">The logging builder to configure.</param>
186
+
/// <param name="configureLogger">The delegate for configuring the <see cref="Serilog.LoggerConfiguration" /> that will be used to construct a <see cref="Serilog.Core.Logger" />.</param>
187
+
/// <param name="preserveStaticLogger">Indicates whether to preserve the value of <see cref="Serilog.Log.Logger"/>.</param>
188
+
/// <param name="writeToProviders">By default, Serilog does not write events to <see cref="ILoggerProvider"/>s registered through
189
+
/// the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify
190
+
/// <c>true</c> to write events to all providers.</param>
/// <summary>Sets Serilog as the logging provider.</summary>
213
+
/// <remarks>
214
+
/// A <see cref="ILoggingBuilder"/> is supplied so that configuration and hosting information can be used.
215
+
/// The logger will be shut down when application services are disposed.
216
+
/// </remarks>
217
+
/// <param name="builder">The logging builder to configure.</param>
218
+
/// <param name="configureLogger">The delegate for configuring the <see cref="Serilog.LoggerConfiguration" /> that will be used to construct a <see cref="Serilog.Core.Logger" />.</param>
219
+
/// <param name="preserveStaticLogger">Indicates whether to preserve the value of <see cref="Serilog.Log.Logger"/>.</param>
220
+
/// <param name="writeToProviders">By default, Serilog does not write events to <see cref="ILoggerProvider"/>s registered through
221
+
/// the Microsoft.Extensions.Logging API. Normally, equivalent Serilog sinks are used in place of providers. Specify
222
+
/// <c>true</c> to write events to all providers.</param>
0 commit comments