| | | 1 | | using Serilog.Events; |
| | | 2 | | |
| | | 3 | | namespace Kestrun.Middleware; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Options controlling the behaviour of the <see cref="CommonAccessLogMiddleware"/>. |
| | | 7 | | /// </summary> |
| | | 8 | | public sealed class CommonAccessLogOptions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// The default timestamp format used by Apache HTTPD common/combined logs. |
| | | 12 | | /// </summary> |
| | | 13 | | public const string DefaultTimestampFormat = "dd/MMM/yyyy:HH:mm:ss zzz"; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets or sets the log level used when writing access log entries. |
| | | 17 | | /// </summary> |
| | 29 | 18 | | public LogEventLevel Level { get; set; } = LogEventLevel.Information; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets or sets a value indicating whether the request query string should be included in the request line. |
| | | 22 | | /// </summary> |
| | 26 | 23 | | public bool IncludeQueryString { get; set; } = true; |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets or sets a value indicating whether the request protocol should be included in the request line. |
| | | 27 | | /// </summary> |
| | 26 | 28 | | public bool IncludeProtocol { get; set; } = true; |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Gets or sets a value indicating whether the elapsed request time in milliseconds should be appended to the log e |
| | | 32 | | /// </summary> |
| | 6 | 33 | | public bool IncludeElapsedMilliseconds { get; set; } |
| | | 34 | | = false; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets or sets a value indicating whether the timestamp should be written using UTC time rather than the server lo |
| | | 38 | | /// </summary> |
| | 5 | 39 | | public bool UseUtcTimestamp { get; set; } |
| | | 40 | | = false; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets or sets the timestamp format used when rendering the access log entry. |
| | | 44 | | /// </summary> |
| | 29 | 45 | | public string TimestampFormat { get; set; } = DefaultTimestampFormat; |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets or sets the name of the HTTP header that should be consulted for the client address |
| | | 49 | | /// (for example <c>X-Forwarded-For</c>). When the header is missing the connection remote address is used. |
| | | 50 | | /// </summary> |
| | 5 | 51 | | public string? ClientAddressHeader { get; set; } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// Gets or sets the time provider used when rendering timestamps. |
| | | 55 | | /// </summary> |
| | 24 | 56 | | public TimeProvider TimeProvider { get; set; } = TimeProvider.System; |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets or sets the Serilog logger used to emit access log entries. When not specified the |
| | | 60 | | /// middleware will use the application logger registered in dependency injection. |
| | | 61 | | /// </summary> |
| | 6 | 62 | | public Serilog.ILogger? Logger { get; set; } |
| | | 63 | | } |