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/Middleware/HttpLogging/src/HttpLoggingAttribute.cs
+53-12Lines changed: 53 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -13,32 +13,73 @@ public sealed class HttpLoggingAttribute : Attribute
13
13
/// Initializes an instance of the <see cref="HttpLoggingAttribute"/> class.
14
14
/// </summary>
15
15
/// <param name="loggingFields">Specifies what fields to log for the endpoint.</param>
16
-
/// <param name="requestBodyLogLimit">Specifies the maximum number of bytes to be logged for the request body. A value of <c>-1</c> means use the default setting in <see cref="HttpLoggingOptions.RequestBodyLogLimit"/>.</param>
17
-
/// <param name="responseBodyLogLimit">Specifies the maximum number of bytes to be logged for the response body. A value of <c>-1</c> means use the default setting in <see cref="HttpLoggingOptions.ResponseBodyLogLimit"/>.</param>
18
-
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="requestBodyLogLimit"/> or <paramref name="responseBodyLogLimit"/> is less than <c>-1</c>.</exception>
/// Specifies the maximum number of bytes to be logged for the request body.
37
36
/// </summary>
38
-
publicintRequestBodyLogLimit{get;}
37
+
/// <exception cref="ArgumentOutOfRangeException">Thrown when <see cref="RequestBodyLogLimit"/> set to a value less than <c>0</c>.</exception>
38
+
/// <exception cref="InvalidOperationException">Thrown when getting <see cref="RequestBodyLogLimit"/> if it hasn't been set to a value. Check <see cref="IsRequestBodyLogLimitSet"/> first.</exception>
39
+
publicintRequestBodyLogLimit
40
+
{
41
+
get
42
+
{
43
+
if(IsRequestBodyLogLimitSet)
44
+
{
45
+
return_requestBodyLogLimit;
46
+
}
47
+
48
+
thrownewInvalidOperationException($"{nameof(RequestBodyLogLimit)} was not set. Check {nameof(IsRequestBodyLogLimitSet)} before accessing this property.");
/// Specifies the maximum number of bytes to be logged for the response body.
42
65
/// </summary>
43
-
publicintResponseBodyLogLimit{get;}
66
+
/// <exception cref="ArgumentOutOfRangeException">Thrown when <see cref="ResponseBodyLogLimit"/> set to a value less than <c>0</c>.</exception>
67
+
/// <exception cref="InvalidOperationException">Thrown when getting <see cref="ResponseBodyLogLimit"/> if it hasn't been set to a value. Check <see cref="IsResponseBodyLogLimitSet"/> first.</exception>
68
+
publicintResponseBodyLogLimit
69
+
{
70
+
get
71
+
{
72
+
if(IsResponseBodyLogLimitSet)
73
+
{
74
+
return_responseBodyLogLimit;
75
+
}
76
+
thrownewInvalidOperationException($"{nameof(ResponseBodyLogLimit)} was not set. Check {nameof(IsResponseBodyLogLimitSet)} before accessing this property.");
Copy file name to clipboardExpand all lines: src/Middleware/HttpLogging/src/HttpLoggingEndpointConventionBuilderExtensions.cs
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,11 +19,22 @@ public static class HttpLoggingEndpointConventionBuilderExtensions
19
19
/// <param name="requestBodyLogLimit">Sets the <see cref="HttpLoggingOptions.RequestBodyLogLimit"/> for this endpoint. A value of <c>-1</c> means use the default setting in <see cref="HttpLoggingOptions.RequestBodyLogLimit"/>.</param>
20
20
/// <param name="responseBodyLogLimit">Sets the <see cref="HttpLoggingOptions.ResponseBodyLogLimit"/> for this endpoint. A value of <c>-1</c> means use the default setting in <see cref="HttpLoggingOptions.ResponseBodyLogLimit"/>.</param>
21
21
/// <returns>The original convention builder parameter.</returns>
22
-
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="requestBodyLogLimit"/> or <paramref name="responseBodyLogLimit"/> is less than <c>-1</c>.</exception>
/// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="requestBodyLogLimit"/> or <paramref name="responseBodyLogLimit"/> is less than <c>0</c>.</exception>
0 commit comments