I have a class that wraps NLog (called NLogger). My logs are saved to my database. The thing I\'m having a problem with is how do I show where the logging occured. I have th
There is an easy way to achieve this. Just add these attributes to your log wrapper method signatures:
void Log(LogSeverity severity, string message, [CallerFilePath] string fileName = null, [CallerMemberName] string member = null, [CallerLineNumber] int? lineNumber = null);
and pass these to the wrapped NLog methods.
See https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerfilepathattribute?view=netframework-4.7.2 for more info on System.Runtime.CompilerServices attibutes in .NET.