Produces logger events
on logger level error
under the hierarchical logger domain:
[otp, inets, httpd, ServerID, error]
The built in logger formatting function produces log entries from the error reports:
#{server_name => string()
protocol => internal | 'TCP' | 'TLS' | 'HTTP',
transport => "TCP "| "TLS", %% Present when protocol = 'HTTP'
uri => string(), %% Present when protocol = 'HTTP' and URI is valid
peer => inet:peername(),
host => inet:hostname(),
reason => term()
}
An example of a log entry with only default settings of logger
=ERROR REPORT==== 9-Oct-2019::09:33:27.350235 ===
Server: My Server
Protocol: HTTP
Transport: TLS
URI: /not_there
Host: 127.0.1.1:80
Peer: 127.0.0.1:45253
Reason: [{statuscode,404},{description,"Object Not Found"}]
Using this option makes mod_log and mod_disk_log error logs redundant.
Add the filter
{fun logger_filters:domain/2,
{log,equal,[otp,inets, httpd, ServerID, error]}
to appropriate logger handler to handle the events. For example to write the error log from an httpd server with a
ServerID
of
my_server
to a file you can use the following sys.config:
[{kernel,
[{logger,
[{handler, http_error_test, logger_std_h,
#{config => #{ file => "log/http_error.log" },
filters => [{inets_httpd, {fun logger_filters:domain/2,
{log, equal,
[otp, inets, httpd, my_server, error]
}}}],
filter_default => stop }}]}]}].
or if you want to add it to the default logger via an API:
logger:add_handler_filter(default,
inets_httpd,
{fun logger_filters:domain/2,
{log, equal,
[otp, inets, httpd, my_server, error]}}).