RequestLogsFeature and AWS DynamoDb

I am building a custom RequestLogger to DynamoDb using the PocoDynamo Feature.

I am just overriding the InMemoryRollingRequestLogger. Seems pretty straight forward.

public class DynamoRequestLogger : InMemoryRollingRequestLogger
{

public override void Log(IRequest request, object requestDto, object response, TimeSpan requestDuration)
{

        if (ShouldSkip(request, requestDto))
            return;

        var requestType = requestDto?.GetType();
        var entry = CreateEntry(request, requestDto, response, requestDuration, requestType);

        Db.PutItem<RequestLogEntry>(entry);
    }

However, persisting the object to dynamo in this fashion does not serialize the request or response dtos (just the type name).

What is the best approach to store the serialized DTO data?

I’m assuming it’s because it can’t de/serialize unknown object properties, many typed serializers and persistent providers don’t support this.

You can try serializing the object yourself as a string, e.g:

entry.Response = entry.Response.ToJson();

Personally I find the JSV format more human readable, e.g

entry.Response = entry.Response.ToJsv();

entry.Response = entry.Response.Dump(); //prettified indented version