Logging Failed Model data in ELMAH

36 views Asked by At

How to log something like List<CustomModel> in ELMAH?

Tried the following however it doesn't work:

Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Error Model " + CustomModel));

1

There are 1 answers

0
ThomasArdal On

ELMAH doesn't support custom properties like other frameworks (log4net, Serilog etc.). If you want to store the content of the list, you can use something like json.net to serialize the list to a JSON string before sending it to ELMAH:

Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Error Model " + JsonConvert.SerializeObject(CustomModel);));