-
-
Notifications
You must be signed in to change notification settings - Fork 45
HTTP sink
FantasticFiasco edited this page Oct 1, 2018
·
15 revisions
The non-durable HTTP sink will send log events using HTTP POST over the network. A non-durable sink will lose data after a system or process restart.
ILogger log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Http("www.mylogs.com")
.CreateLogger();
log.Information("Logging {@Heartbeat} from {Computer}", heartbeat, computer);Used in conjunction with Serilog.Settings.Configuration the same sink can be configured in the following way:
{
"Serilog": {
"MinimumLevel": "Verbose",
"WriteTo": [
{
"Name": "Http",
"Args": {
"requestUri": "www.mylogs.com"
}
}
]
}
}The following arguments are available when creating a HTTP sink.
-
requestUri- The URI the request is sent to. -
batchPostingLimit- The maximum number of events to post in a single batch. Default value is 1000. -
queueLimit- The maximum number of events stored in the queue in memory, waiting to be posted over the network. Default value is infinitely. -
period- The time to wait between checking for event batches. Default value is 2 seconds. -
textFormatter- The formatter rendering individual log events into text, for example JSON. Default value isNormalRenderedTextFormatter. -
batchFormatter- The formatter batching multiple log events into a payload that can be sent over the network. Default value isDefaultBatchFormatter. -
restrictedToMinimumLevel- The minimum level for events passed through the sink. Default value isLevelAlias.Minimum. -
httpClient- A customIHttpClientimplementation. Default value isHttpClient.