-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Labels
Description
Hi,
I'm trying to use this in a web api, however, the tryRead is a synchronous action and is causing the application to throw an exception.
Do you recommend enabling Server.AllowSynchronousIO = true?
This is my current workaround:
[HttpPost("api/log-events")]
public async Task<IActionResult> Post()
{
Serilog.Events.LogEvent evt;
var apiKey = Request.Headers["X-HEIMDALL-KEY"].FirstOrDefault();
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
var log = new LogEventReader(reader);
string line;
while (!string.IsNullOrWhiteSpace(line = await reader.ReadLineAsync()))
{
evt = LogEventReader.ReadFromString(line);
Log.Logger.Information(evt.RenderMessage());
_publisher.Publish<LogEvent>("test", evt);
}
};
return Ok();
}