Hello,
I have some code that is trying to log when an error occurs. It only happens in production so I can't easily reproduce it so I'm trying to catch it in the log. I have the following code:
catch (Exception ex)
{
var ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
Dynamicweb.Logging.LogManager.Current.GetLogger(LogFolder).Error($"Failed creating switchaccount cookie. UserId: {itemUser.ID}. IP Address: {ip}. {ex.Message}");
}
Note that I'm doing a null check for itemUser prior to this code, so I know that it's not null. And LogFolder is a valid string.
However, the log entry is just this:
2022-03-12 00:45:04.7199|INFO|DynamicwebNA/AutoImpersonate|Object reference not set to an instance of an object.
Notice that it's an INFO log and not an Error log, and it doesn't output the message that I intended.
What do I have wrong in the syntax for the logger?