|
drogon
C++14/17-based HTTP application framework
|
This plugin is used to print all requests to the log. More...
#include <drogon/plugins/AccessLogger.h>


Public Member Functions | |
| void | initAndStart (const Json::Value &config) override |
| void | shutdown () override |
| Public Member Functions inherited from drogon::PluginBase | |
| void | initialize () |
| This method must be called by drogon. | |
| Public Member Functions inherited from drogon::DrObject< AccessLogger > | |
| const std::string & | className () const override |
| Get the class name. | |
| bool | isClass (const std::string &class_name) const override |
| Return true if the class name is 'class_name'. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from drogon::DrObject< AccessLogger > | |
| static const std::string & | classTypeName () |
This plugin is used to print all requests to the log.
The json configuration is as follows:
log_format: a format string for access logging, there are several placeholders that represent particular data. $date: the time when the log was printed. $request_date: the time when the request was created. $request_path|$path: the path of the request. $request_query|$query: the query string of the request. $request_url|$url: the URL of the request, equals to $request_path+"?"+$request_query. $request_version|$version: the http version string. $request: the full request line. $remote_addr: the remote address $local_addr: the local address $request_len|$body_bytes_received: the content length of the request. $method: the HTTP method of the request. $thread: the current thread number. $response_len|$body_bytes_sent: the content length of the response. $http_[header_name]: the header of the request. $cookie_[cookie_name]: the cookie of the request. $upstream_http_[header_name]: the header of the response sent to the client. $status_code: the status code of the response. $status: the status code and string of the response. $processing_time: request processing time in seconds with a microseconds resolution; time elapsed between the request object was created and response object was created.
use_spdlog: log using spdlog, disabled by default.
log_path: Log file path, empty by default,in which case,logs are output to the regular log file (or stdout based on the log configuration).
log_file: The access log file name, 'access.log' by default. if the file name does not contain a extension, the .log extension is used.
log_size_limit: 0 bytes by default, when the log file size reaches "log_size_limit", the log file is switched. Zero value means never switch
max_files: 0 by default, when the number of old log files exceeds max_files, the oldest log file will be deleted. 0 means never delete.
log_index: The index of log output, 0 by default.
show_microseconds: Whether print microsecond in time. True by default.
custom_time_format: Provide a custom format for time. If not provided or empty, the default format is "%Y%m%d %H:%M:%S", with microseconds followed if show_microseconds is true. For detailed information about formats, please refer to cpp reference about strftime().
use_real_ip: Log the real ip of peer. This option only takes effects when set to true and RealIpResolver is enabled. False by default.
Enable the plugin by adding the configuration to the list of plugins in the configuration file.
path_exempt: must be a string or a string array, present a regular expression (for matching the path of a request) or a regular expression list for URLs that don't have to be logged.
|
overridevirtual |
This method must be called by drogon to initialize and start the plugin. It must be implemented by the user.
Implements drogon::PluginBase.
|
overridevirtual |
This method must be called by drogon to shutdown the plugin. It must be implemented by the user.
Implements drogon::PluginBase.