|
2 | 2 | using Serilog.Configuration;
|
3 | 3 | using Serilog.Core;
|
4 | 4 | using Serilog.Events;
|
| 5 | +using Serilog.Formatting; |
5 | 6 | using Serilog.Formatting.Display;
|
6 | 7 | using Serilog.Sinks.SystemConsole;
|
7 | 8 |
|
@@ -36,6 +37,28 @@ public static LoggerConfiguration Console(
|
36 | 37 | if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
|
37 | 38 | if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate));
|
38 | 39 | var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
|
| 40 | + return Console(sinkConfiguration, formatter, restrictedToMinimumLevel, levelSwitch); |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Writes log events to <see cref="System.Console"/>. |
| 45 | + /// </summary> |
| 46 | + /// <param name="sinkConfiguration">Logger sink configuration.</param> |
| 47 | + /// <param name="formatter">Controls the rendering of log events into text, for example to log JSON. To |
| 48 | + /// control plain text formatting, use the overload that accepts an output template.</param> |
| 49 | + /// <param name="restrictedToMinimumLevel">The minimum level for |
| 50 | + /// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param> |
| 51 | + /// <param name="levelSwitch">A switch allowing the pass-through minimum level |
| 52 | + /// to be changed at runtime.</param> |
| 53 | + /// <returns>Configuration object allowing method chaining.</returns> |
| 54 | + public static LoggerConfiguration Console( |
| 55 | + this LoggerSinkConfiguration sinkConfiguration, |
| 56 | + ITextFormatter formatter, |
| 57 | + LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, |
| 58 | + LoggingLevelSwitch levelSwitch = null) |
| 59 | + { |
| 60 | + if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration)); |
| 61 | + if (formatter == null) throw new ArgumentNullException(nameof(formatter)); |
39 | 62 | return sinkConfiguration.Sink(new ConsoleSink(formatter), restrictedToMinimumLevel, levelSwitch);
|
40 | 63 | }
|
41 | 64 | }
|
|
0 commit comments