Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automapper add logging to Map method

Is there any possibility to add logging (like nlog) to automapper map method ?

I will really want to have logged info about all mappings between objects.

Thanks

like image 370
dzaba Avatar asked Jan 25 '14 13:01

dzaba


1 Answers

You can use the BeforeMap event:

Mapper.CreateMap<SourceType, DestinationType>().BeforeMap((src, dst) =>
{
     SomeStaticLogger.DebugFormat("Mapping stuff from {0} to {1}", src, dst);
});
like image 122
stuartd Avatar answered Oct 17 '22 06:10

stuartd