Logging component
Allows to configure the default logger and/or additional loggers for your needs.
Static options:
Name | Description | Default value |
file_path | path to the log file | - |
level | log verbosity | info |
format | log output format, either tskv or ltsv | tskv |
flush_level | messages of this and higher levels get flushed to the file immediately | warning |
message_queue_size | the size of internal message queue, must be a power of 2 | 65536 |
overflow_behavior | message handling policy while the queue is full: discard drops messages, block waits until message gets into the queue | discard |
testsuite-capture | if exists, setups additional TCP log sink for testing purposes | {} |
fs-task-processor | task processor for disk I/O operations for this logger | fs-task-processor of the loggers component |
Logs output
You can specify logger output, in file_path
option:
- Use
@stdout
to write your logs to standard output stream;
- Use
@stderr
to write your logs to standard error stream;
- Use
@null
to suppress sending of logs;
- Use
file_name%
to write your logs in file. Use USR1 signal or OnLogRotate
handler to reopen files after log rotation;
- Use
unix:socket_name%
to write your logs to unix socket. Socket must be created before the service starts and closed by listener afert service is shuted down.
testsuite-capture options:
Name | Description | Default value |
host | testsuite hostname, e.g. localhost | - |
port | testsuite port | - |
Static configuration example:
# yaml
logging:
fs-task-processor: fs-task-processor
loggers:
access:
file_path: $access_log_path
overflow_behavior: discard
format: raw
access-tskv:
file_path: $access_tskv_log_path
overflow_behavior: discard
format: raw
default:
file_path: $default_log_path
level: $log_level
level#fallback: debug
overflow_behavior: discard
tracer:
file_path: '@stdout'
overflow_behavior: discard
default
section configures the default logger for LOG_*.
Definition at line 79 of file component.hpp.
|
| Logging (const ComponentConfig &, const ComponentContext &) |
| The component constructor.
|
|
logging::LoggerPtr | GetLogger (const std::string &name) |
| Returns a logger by its name.
|
|
logging::LoggerPtr | GetLoggerOptional (const std::string &name) |
| Returns a logger by its name.
|
|
void | StartSocketLoggingDebug (const std::optional< logging::Level > &log_level) |
|
void | StopSocketLoggingDebug (const std::optional< logging::Level > &log_level) |
|
void | OnLogRotate () |
| Reopens log files after rotation.
|
|
void | TryReopenFiles () |
|
void | WriteStatistics (utils::statistics::Writer &writer) const |
|