Add this as property to the NLogLogger-class (Use Log instead of constantly calling GetCurrentClassLogger) :
private ILogger Log { get { return _log ?? (_log = LogManager.GetCurrentClassLogger()); } }
ILogger _log;
Improve the following method:
|
private void SendLog(object message, LogLevel level, IDictionary<string, object> properties, Exception exception = null) |
|
{ |
|
var propertiesLocal = properties ?? new Dictionary<string, object>(); |
By adding IsEnabled-check to the beginning of the SendLog-method above:
if (!Log.IsEnabled(level))
return;
var propertiesLocal = properties ?? new Dictionary<string, object>();
Introduce this new SendLog method with the following parameters (And fix all Log-methods that calls BuildProperties to instead pass ILogEntry to this new method):
void SendLog(object message, LogLevel level, ILogEntry logEntry, Exception exception = null)
{
if (!Log.IsEnabled(level))
return;
SendLog(message, level, BuildProperties(logEntry), exception);
}
Modify the this SendLog-method:
|
private void SendLog(object message, LogLevel level, Exception exception = null) |
|
{ |
|
SendLog(message, level, new Dictionary<string, object>(), exception); |
So it becomes:
void SendLog(object message, LogLevel level, Exception exception = null)
{
if (!Log.IsEnabled(level))
return;
SendLog(message, level, new Dictionary<string, object>(), exception);
}
Add this as property to the
NLogLogger-class (UseLoginstead of constantly callingGetCurrentClassLogger) :Improve the following method:
das-shared-packages/Logging/Logger/SFA.DAS.NLog.Logger/NLogLogger.cs
Lines 185 to 187 in d1a0f36
By adding
IsEnabled-check to the beginning of theSendLog-method above:Introduce this new
SendLogmethod with the following parameters (And fix all Log-methods that callsBuildPropertiesto instead passILogEntryto this new method):Modify the this
SendLog-method:das-shared-packages/Logging/Logger/SFA.DAS.NLog.Logger/NLogLogger.cs
Lines 140 to 142 in d1a0f36
So it becomes: