RedLock.net
                                
                                
                                
                                    RedLock.net copied to clipboard
                            
                            
                            
                        Logging improvements
Some times I have following issues: Failed to extend lock, NoQuorum (Acquired: 0, Conflicted: 0, Error: 1)
It is hard to find details about error preventing lock extension because it is logged with "Debug" level. logger.LogDebug($"Error extending lock instance {host}: {ex.Message}");
I would propose to have following improvements in logging:
- Create and use EventId for every log message
 - Pass entire exception to logger
 - Be able to configure log level for some key events
 
For instance in my case it might be like
public static class LogEvents
    {
        public static EventId ErrorExtendingLockInstance = new EventId(123, "ErrorExtendingLockInstance");
    }
logger.LogDebug(LogEvents.ErrorExtendingLockInstance, ex, $"Error extending lock instance {host}: {ex.Message}");
Right now can't propose how to make log level for events configurable, but it should be doable.