Reference
.NET reference
The parameters of the Apitally SDK for .NET.
Configuration options
The following parameters apply when configuring Apitally options for your ASP.NET Core application.
Parameter | Description | Type |
---|---|---|
ClientId | Client ID for your application. Find it on the Setup instructions page for your app. | string |
Env | Name of the environment, e.g. prod or dev . The environment will be automatically created if it doesn’t exist. | string |
RequestLogging | Configuration for request logging. See table below. | RequestLoggingOptions |
Request logging options
The following are the properties of the RequestLoggingOptions
class.
Parameter | Description | Type | Default |
---|---|---|---|
Enabled | Whether request logging is enabled. | bool | false |
IncludeQueryParams | Whether to include query parameters in the logs. If disabled, these will be stripped from the request URLs logged. | bool | true |
IncludeRequestHeaders | Whether to include request headers in the logs. Default masking for common sensitive headers (e.g. Authorization ) applies. | bool | false |
IncludeRequestBody | Whether to include the request body in the logs. Only JSON and text are supported, up to 50 KB. | bool | false |
IncludeResponseHeaders | Whether to include response headers in the logs. | bool | true |
IncludeResponseBody | Whether to include the response body in the logs. Only JSON and text are supported, up to 50 KB. | bool | false |
QueryParamMaskPatterns | List of regular expressions for matching query parameters to mask. These are in addition to the default masking patterns. | List<string> | [] |
HeaderMaskPatterns | List of regular expressions for matching headers to mask. These are in addition to the default masking patterns. | List<string> | [] |
BodyFieldMaskPatterns | List of regular expressions for matching request/response body fields to mask. These are in addition to the default masking patterns. | List<string> | [] |
PathExcludePatterns | List of regular expressions for matching paths to exclude from logging. | List<string> | [] |
MaskRequestBody | Function to mask sensitive data in the request body. Return null to mask the whole body. | Func<Request, byte[]?> | - |
MaskResponseBody | Function to mask sensitive data in the response body. Return null to mask the whole body. | Func<Request, Response, byte[]?> | - |
ShouldExclude | Function to determine whether a request should be excluded from logging. Return true to exclude the request. | Func<Request, Response, bool> | - |
Request object
Below are the properties of the Request
objects that are passed to the user-provided callback functions.
Property | Description | Type |
---|---|---|
Timestamp | Unix timestamp of the request. | long |
Consumer | Identifier of the consumer making the request. | string |
Method | HTTP method of the request. | string |
Path | Path of the request. | string |
Url | Full URL of the request. | string |
Headers | Array of key-value pairs representing the request headers. | Header[] |
Size | Size of the request body in bytes. | int |
Body | Raw request body as bytes. | byte[] |
Response object
Below are the properties of the Response
objects that are passed to some of the user-provided callback functions.
Property | Description | Type |
---|---|---|
StatusCode | HTTP status code of the response. | int |
ResponseTime | Time taken to respond to the request in seconds. | double |
Headers | Array of key-value pairs representing the response headers. | Header[] |
Size | Size of the response body in bytes. | int |
Body | Raw response body as bytes. | byte[] |
Default masking
The below regular expressions are used to mask sensitive query parameters, headers and request/response body fields.
Default exclusions
The below regular expressions are used to exclude common health check endpoints from logging. They are applied to the request path.