Im using NLog 4.5.11 for logging and moq 4.10.1 for mocking.
I have a middleware which writes exception details to the log file using NLog.
I need to unit test middleware in my API project and check the logged message for proper values.
This is how i have declared exception logger :
private static Logger _exceptionLogger = LogManager.GetLogger("ExceptionLogger");
This is how im initializing Logmanager in middlewares constructor :
LogManager.LoadConfiguration(String.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
and this is how im logging the exception message :
_exceptionLogger.Error(exceptionMessage);
Is there any way we can do this without actually writing and reading logged message in a file ?