Search code examples
raygun

RaygunMessage does not list request data


It is critical to us that we do not log post data (i.e. the POST body of HTTP POST requests) in Raygun. However, all other request data is fine.

We were previously calling the overload of RaygunClient.Send() which accepts an exception, like this:

client.Send(myExeption, null, myCustomData);

This was gathering data about the request and logging it. This was great, except it was also logging the post data, which is sensitive.

I made some modifications based on this link which involved calling the overload of RaygunClient.Send() which accepts a RaygunMessage:

var message = RaygunMessageBuilder.New
                .SetEnvironmentDetails()
                .SetMachineName(Environment.MachineName)
                .SetExceptionDetails(myException)
                .SetClientDetails()
                .SetVersion("a build")
                .SetTags(new[] { "a Tag" })
                .SetUserCustomData(myCustomData)
                .Build();

            RayGun.Send(message);

(Note that I haven't yet attempted to nix the post data.)

I'm now finding that the logs contain no request data whatsoever! So it appears that either:

  1. Using a RaygunMessage prevents request data being collected
  2. I'm not configuring the RaygunMessage correctly

Can anyone advise what I should do to withhold post data from the logging logic while still getting the rest of the request data?


Solution

  • Finally! After some trawling on https://github.com/MindscapeHQ/raygun4net.

    var message = RaygunMessageBuilder.New
                    .SetEnvironmentDetails()
                    .SetMachineName(Environment.MachineName)
                    .SetExceptionDetails(myException)
                    .SetClientDetails()
                    .SetVersion("Build:")
                    .SetTags(new[] { "Tag" })
                    .SetUserCustomData(myCustomData)
                    .Build();
    
                var request = GetHttpRequest();
    
            var requestMessage = RaygunRequestMessageBuilder.Build(request, null);
            requestMessage.RawData = "Post data withheld";
    
            message.Details.Request = requestMessage;
    
            RayGun.Send(message);