I need a redacting feature like nodeJS pino in .net core.
I need to log objects but since they hold sensitive data, i cant log property values. But i need to log as much information as possible. For example i have
public class Car
{
public string Name { get; set; }
public string Size { get; set; }
public int Height { get; set; }
public List<Tire> Tires { get; set; } = new List<Tire>();
}
public class Tire
{
public string Name { get; set; }
public int Diameter { get; set; }
public int Area { get; set; }
}
And let
Car car = new Car();
car.Height = 1;
car.Name = "good boy";
car.Size = "long";
Tire tire1 = new Tire();
tire1.Area = 10;
tire1.Diameter = 20;
tire1.Name = "tire 1";
Tire tire2 = new Tire();
tire2.Area = 22;
tire2.Diameter = 33;
car.Tires.Add(tire1);
car.Tires.Add(tire2);
I want
logObject(car)
produce a string
{
"Name": "string",
"Size": "string",
"Height": "int",
"Tires": [
{
"Name": "string",
"Diameter": "int",
"Area": "int"
},
{
"Name": "null",
"Diameter": int,
"Area": int
}
]
}
Note that when the value is null, it prints null.
Is there this kind of logger in .net core? Or is there a serializer like this?