Skip to main content
You can configure Apitally when registering the service in your Program.cs file or in your appsettings.json file.
using Apitally;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddApitally(options =>
{
    options.ClientId = "your-client-id";
    options.Env = "dev";
    options.RequestLogging.Enabled = true;
    // other parameters ...
});

var app = builder.Build();
app.UseApitally();

Parameters

The following configuration parameters are available. Only ClientId and Env are required.
ParameterDescriptionType
ClientIdClient ID for your application. Find it on the Setup instructions page for your app.string
EnvName of the environment, e.g. prod or dev. The environment will be automatically created if it doesn’t exist.string
RequestLoggingConfiguration for request logging. See table below.RequestLoggingOptions
The RequestLogging parameter is an object with the following properties:
ParameterDescriptionTypeDefault
EnabledWhether request logging is enabled.boolfalse
IncludeQueryParamsWhether to include query parameters in the logs. If disabled, these will be stripped from the request URLs logged.booltrue
IncludeRequestHeadersWhether to include request headers in the logs. Default masking for common sensitive headers (e.g. Authorization) applies.boolfalse
IncludeRequestBodyWhether to include the request body in the logs. Only JSON and text are supported, up to 50 KB.boolfalse
IncludeResponseHeadersWhether to include response headers in the logs.booltrue
IncludeResponseBodyWhether to include the response body in the logs. Only JSON and text are supported, up to 50 KB.boolfalse
IncludeExceptionWhether to include exception details in the logs.booltrue
CaptureLogsWhether to capture application logs emitted during request handling.boolfalse
CaptureTracesWhether to enable tracing using System.Diagnostics.boolfalse
QueryParamMaskPatternsList of regular expressions for matching query parameters to mask. These are in addition to the default masking patterns.List<string>[]
HeaderMaskPatternsList of regular expressions for matching headers to mask. These are in addition to the default masking patterns.List<string>[]
BodyFieldMaskPatternsList of regular expressions for matching request/response body fields to mask. These are in addition to the default masking patterns.List<string>[]
PathExcludePatternsList of regular expressions for matching paths to exclude from logging.List<string>[]
MaskRequestBodyFunction to mask sensitive data in the request body. Return null to mask the whole body.Func<Request, byte[]?>-
MaskResponseBodyFunction to mask sensitive data in the response body. Return null to mask the whole body.Func<Request, Response, byte[]?>-
ShouldExcludeFunction to determine whether a request should be excluded from logging. Return true to exclude the request.Func<Request, Response, bool>-