http_appender: Log Messages via HTTP

Description Usage Arguments See Also Examples

View source: R/appenders.R

Description

Send messages in the body of HTTP requests. Responses with status code 400 or above will trigger errors.

Requires the httr package.

Usage

1
http_appender(url, method = "POST", layout = default_log_layout(), ...)

Arguments

url

The URL to submit messages to.

method

The HTTP method to use, usually "POST" or "GET".

layout

A layout function taking a level parameter and additional arguments corresponding to the message.

...

Further arguments passed on to POST.

See Also

appenders for more information on Appenders.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# POST messages to localhost.
appender <- http_appender("localhost")
appender("INFO", "Message.")

# POST JSON-encoded messages.
appender <- http_appender(
  "localhost", method = "POST", layout = default_log_layout(),
  httr::content_type_json()
)
appender("INFO", "Message.")

## End(Not run)

log4r documentation built on Nov. 4, 2021, 9:09 a.m.