ServiceStack.CloudTrail.RequestLogsFeature
1.0.1
dotnet add package ServiceStack.CloudTrail.RequestLogsFeature --version 1.0.1
NuGet\Install-Package ServiceStack.CloudTrail.RequestLogsFeature -Version 1.0.1
<PackageReference Include="ServiceStack.CloudTrail.RequestLogsFeature" Version="1.0.1" />
paket add ServiceStack.CloudTrail.RequestLogsFeature --version 1.0.1
#r "nuget: ServiceStack.CloudTrail.RequestLogsFeature, 1.0.1"
// Install ServiceStack.CloudTrail.RequestLogsFeature as a Cake Addin
#addin nuget:?package=ServiceStack.CloudTrail.RequestLogsFeature&version=1.0.1
// Install ServiceStack.CloudTrail.RequestLogsFeature as a Cake Tool
#tool nuget:?package=ServiceStack.CloudTrail.RequestLogsFeature&version=1.0.1
ServiceStack.CloudTrail.RequestLogsFeature
A ServiceStack plugin that logs requests to AWS CloudTrail as JSON. For more details on JSON logging to CloudTrail, please review this page and this page.
*NB. This version is compatible with ServiceStack v8.x.
Installing
The package is available from nuget.org
Install-Package Servicestack.CloudTrail.RequestLogsFeature
Requirements
You must have an AWS account and a user with access key and secret created.
Quick Start
In your AppHost
class Configure
method, add the plugin. By default configuration values are read from the registered IAppSettings
instance. By default this will be an instance of AppSettings
, if an alternative implementation of IAppSettings
is to be used it must be registered prior to this plugin being registered.
Alternatively all configuration options are exposed as public properties of the feature class.
public override void Configure(Container container)
{
// Basic setup. All config read from AppSettings
Plugins.Add(new CloudTrailRequestLogsFeature());
var logger = new CloudTrailRequestLogsFeature
{
// required parameter
AwsAccessKeyId = "logger_user_key_id",
// required parameter
AwsSecretAccessKey = "logger_secret_access_key",
// a region code from the list: https://www.aws-services.info/regions.html
// required parameter
Region = "ca-central-1",
// this is the name of the log group shown within the cloudtrail UI
// required parameter
LogGroupName = "{CompanyName}/Api",
// this can be the individual API instance or ip address of the machine.
// required parameter
LogStreamName = calculatedStreamName,
// add additional properties to Cloudtrail log entry.
AppendProperties = (request, dto, response, duration) => new Dictionary<string, object> { { "NewCustomProperty", "42" } },
// exclude specific dto types from logging
ExcludeRequestDtoTypes = new[] { typeof(HealthCheckService.IsAlive) },
// exclude request body logging for specific dto types
HideRequestBodyForRequestDtoTypes = new[] { typeof(HealthCheckService.IsAlive) },
// custom request logging exclusion
SkipLogging = (request) => request.RawUrl == "/isalive";
};
this.Plugins.Add(logger);
}
Configuration Options
Property | Description | AppSettings key |
---|---|---|
AwsAccessKeyId | AWS access key id. Required | servicestack.cloudtrail.requestlogs.aws.AccessKeyId |
AwsSecretAccessKey | AWS secret access key. Required. | servicestack.cloudtrail.requestlogs.aws.SecretAccessKey |
Region | AWS region. | servicestack.cloudtrail.requestlogs.aws.Region |
LogGroupName | Log group name. Required | servicestack.cloudtrail.requestlogs.LogGroup |
LogStreamName | Log stream name. Required | N/A |
Enabled | Default True | servicestack.cloudtrail.requestlogs.enabled |
EnableErrorTracking | Default True | servicestack.cloudtrail.requestlogs.errortracking.enabled |
EnableRequestBodyTracking | Default False | servicestack.cloudtrail.requestlogs.requestbodytracking.enabled |
EnableSessionTracking | Default False | servicestack.cloudtrail.requestlogs.sessiontracking.enabled |
EnableResponseTracking | Default False | servicestack.cloudtrail.requestlogs.responsetracking.enabled |
AppendProperties | Add additional properties to log | N/A |
RawEventLogger | low evel delegate for custom logging, bypasses all other settings | responsetracking.enabled |
Logger | Swap out cloudtrail logger for custom implementation | responsetracking.enabled |
RequiredRoles | Restrict the runtime configuration to specific roles | servicestack.cloudtrail.requestlogs.requiredroles |
HideRequestBodyForRequestDtoTypes | Type exclusions for body request logging | N/A |
ExcludeRequestDtoTypes | Type exclusions for logging | N/A |
SkipLogging | Skip logging for any custom IRequest conditions | N/A |
Request Correlation
This plugin will detect the default header x-mac-requestid
created by ServiceStack.Request.Correlation
and add this as a property. This is useful for tracking requests from their point of origin across multiple services
Logging in action
Once you start your AppHost
, every request will be now logged to cloudtrail using the default options or the options you provided.
Logging levels are colour coded and depending on your settings, the full requestDto's and even responseDto's are available to search.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- AWSSDK.CloudWatchLogs (>= 3.7.302.11)
- ServiceStack (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.