| | | 1 | | namespace ProjectTemplate.Web.Options; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Options controlling structured HTTP request logging behavior. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class ApplicationRequestLoggingOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Gets the configuration section name used to bind request logging settings. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string SectionName = "ProjectTemplate:RequestLogging"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets a value indicating whether structured request logging is enabled. |
| | | 15 | | /// </summary> |
| | | 16 | | public bool Enabled { get; set; } = true; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets the request/response header used for request correlation. |
| | | 20 | | /// </summary> |
| | | 21 | | public string CorrelationHeaderName { get; set; } = "X-Correlation-ID"; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets or sets a value indicating whether the query string should be logged. |
| | | 25 | | /// Disabled by default because query strings may contain sensitive values. |
| | | 26 | | /// </summary> |
| | | 27 | | public bool IncludeQueryString { get; set; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets or sets a value indicating whether authenticated user names should be logged. |
| | | 31 | | /// </summary> |
| | | 32 | | /// <remarks> |
| | | 33 | | /// Disabled by default. A user name identifies a person, and request logs are typically shipped and retained for |
| | | 34 | | /// longer than the data they describe. Enable this when the application has decided that request attribution is |
| | | 35 | | /// needed and its log retention accounts for personal data. |
| | | 36 | | /// </remarks> |
| | | 37 | | public bool IncludeUserName { get; set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets or sets a value indicating whether the remote IP address should be logged. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <remarks> |
| | | 43 | | /// Disabled by default for the same reason as <see cref="IncludeUserName" />. A client IP address is treated as |
| | | 44 | | /// personal data under several privacy regimes. Enable this when incident response or abuse handling needs it, |
| | | 45 | | /// and note that the value is only meaningful once forwarded headers are configured with trusted proxies. |
| | | 46 | | /// </remarks> |
| | | 47 | | public bool IncludeRemoteIpAddress { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or sets path prefixes that should be excluded from normal request logging. |
| | | 51 | | /// Matching requests are logged at Verbose level so the default sinks suppress them. |
| | | 52 | | /// </summary> |
| | | 53 | | /// <remarks> |
| | | 54 | | /// A configured list replaces these defaults rather than extending them. A blank configured entry is ignored, so a |
| | | 55 | | /// later configuration source can remove an inherited entry by overriding its index with an empty value. |
| | | 56 | | /// </remarks> |
| | | 57 | | public List<string> ExcludedPathPrefixes { get; set; } = |
| | 230 | 58 | | [ |
| | 230 | 59 | | "/health", |
| | 230 | 60 | | "/metrics", |
| | 230 | 61 | | "/favicon.ico", |
| | 230 | 62 | | "/css", |
| | 230 | 63 | | "/js", |
| | 230 | 64 | | "/lib", |
| | 230 | 65 | | "/_framework" |
| | 230 | 66 | | ]; |
| | | 67 | | } |