Skip to content

Implements to log Request Body in application insights after removing the sensitive information.

License

Notifications You must be signed in to change notification settings

amigup/ApplicationInsights.Extension.RequestLogging

Repository files navigation

platforms author
ASP.NET Core 2.2 Web API, Application Insights
amigup

ApplicationInsights.Extension.RequestLogging

Implements to log Request Body in application insights after removing the sensitive information.

Build Status

package Status

Download the package from nuget.org

Scenario

You want to log the Request Body in application Insights after removing the sensitive information so that in Appliation Insights the request body payload can be viewed.

Details

This package is built on

  • ASP.Net Core 2.2 Web API.
  • Microsoft.ApplicationInsights 2.8.1
  • Newtonsoft.Json 12.0.1

Setup

  1. Add RequestLogActionFilterAttribute filter in the MVC pipeline.
services.AddMvc(options =>
 {
       options.Filters.Add<RequestLogActionFilterAttribute>();
 });

How to use

You can attach PII attribute over Properties, Class and Action method parameters.

Property

If PII attribute is attached over property then in Application Insights request log, the actual value is substituted with PII Data string literal.

    public class User
    {
        [PII]
        public string Id { get; set; }

        public string Name { get; set; }

        public DateTime AnneviseryDate { get; set; }

        [PII]
        public int LinkId { get; set; }

        public List<Address> Addresses { get; set; }
    }

Class

If PII attribute is attached over class then object is not logged in Application Insights request log.

    [PII]
    public class User
    {
        
    }

Action method parameter

If PII attribute is attached over parameter then object is not logged in Application Insights request log.

        [HttpPost]
        public void Post([FromBody, PII] User user)
        {
        }

Sample Application

The repository contains a sample application to demostrate the usage of ApplicationInsights.Extension.RequestLogging. Application Insights

About

Implements to log Request Body in application insights after removing the sensitive information.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages