-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Level "Critical" not supported #29
Comments
Thanks for reporting this. @followynne we forgot log lever Critical. Do you have time to fix this? |
@mo-esmp yes, I'll try to give it a look asap this weekend 👍 |
Hey @E4est I'll use it to test more in depth the feat. 😊 |
Sure :) // The JSON payload for the screenshot.
{
"level": "critical",
"messageTemplate": "I hope critical works now. {Remark}",
"properties": [
"That would be so cool."
]
} // The model posted to the log API.
public class LogModel
{
public string? MessageTemplate { get; set; }
public string? Level { get; set; }
public ICollection<object> Properties { get; set; } = new List<object>();
}
// The API controller receiving logs.
[Route("")]
[ApiController]
public class LoggerController : ControllerBase
{
private readonly ILogger _logger;
public LoggerController(ILogger<LoggerController> logger)
{
_logger = logger;
}
[HttpPost("")]
public IActionResult Insert(LogModel model)
{
switch (model.Level?.ToUpperInvariant())
{
case "CRITICAL":
_logger.LogCritical(model.MessageTemplate, model.Properties.ToArray());
break;
case "DEBUG":
_logger.LogDebug(model.MessageTemplate, model.Properties.ToArray());
break;
case "ERROR":
_logger.LogError(model.MessageTemplate, model.Properties.ToArray());
break;
case "TRACE":
_logger.LogTrace(model.MessageTemplate, model.Properties.ToArray());
break;
case "WARNING":
_logger.LogWarning(model.MessageTemplate, model.Properties.ToArray());
break;
default:
LogInvalidModel(model);
return UnprocessableEntity("invalid level");
}
return NoContent();
}
private void LogInvalidModel(LogModel model)
{
_logger.LogError(
"Invalid log model. Received: '{Request}'.",
JsonConvert.SerializeObject(model));
}
} |
@E4est |
I can't filter my logs by Level "Critical".
When I add a critical entry, no level is displayed for the entry.
The text was updated successfully, but these errors were encountered: