You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see there has been a previous bug registered about exceptions not getting passed to log4net so they can be output using the conversion pattern but it is marked as closed. I've run into the same problem and just tried your sample programs with the the controller modified as
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
WeatherForecast[] weatherForecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
_logger.LogTrace("Weather forecast ready!");
_logger.LogError("Weather forecast broken!", new ApplicationException("Exception thrown"));
return weatherForecast;
}
and the Exception is not getting logged even though it is in your conversion patterns
II think the problem with the code above is the order of arguments provided to LogError. LogError(message, ex) tries to format the exception into the string, the correct one is LogError(ex, message).
I see there has been a previous bug registered about exceptions not getting passed to log4net so they can be output using the conversion pattern but it is marked as closed. I've run into the same problem and just tried your sample programs with the the controller modified as
and the Exception is not getting logged even though it is in your conversion patterns
can you confirm this behaviour please.
The text was updated successfully, but these errors were encountered: