Note that writing down the debug or trace logs can significantly affect the performance of the service. In addition to the overhead of writing down more log records, C++ debug symbols may be loaded from the disk to report stack traces. Such IO could lead to significant and unpredictable delays in task processing.
If your service has a server::handlers::LogLevel configured, then you can change the current logging level at runtime, without service restart.
Note that the server::handlers::LogLevel handler lives at the separate components.server.listener-monitor port, so you have to request them using the listener-monitor credentials. See Production configs and best practices for more info on configuration and ideas on how to change the /service/log-level/ handle path.
Examples:
Get the current log-level Note that / is important at the end, without it you might get a response from a different handler.
Note that the server::handlers::LogLevel handler lives at the separate components.server.listener-monitor port, so you have to request them using the listener-monitor credentials. See Production configs and best practices for more info on configuration.
Note that the server::handlers::DynamicDebugLog handler lives at the separate components.server.listener-monitor port, so you have to request them using the listener-monitor credentials. See Production configs and best practices for more info on configuration and ideas on how to change the /service/log/dynamic-debug handle path.
Examples:
Get dynamic debug locations
bash
$ curl -X GET 'http://127.0.0.1:1188/service/log/dynamic-debug'
core/include/userver/rcu/rcu.hpp:208 0
core/include/userver/rcu/rcu.hpp:217 0
core/include/userver/rcu/rcu.hpp:230 0
core/include/userver/rcu/rcu.hpp:239 0
core/include/userver/rcu/rcu.hpp:384 0
core/include/userver/rcu/rcu.hpp:456 0
core/include/userver/rcu/rcu.hpp:461 0
core/include/userver/rcu/rcu.hpp:464 0
core/src/cache/cache_config.cpp:151 0
core/src/cache/cache_config.cpp:194 0
...
Enable dynamic debug for a location
bash
$ curl -X PUT 'http://127.0.0.1:1188/service/log/dynamic-debug?location=core/src/cache/cache_config.cpp:151'
OK
$ curl -X GET 'http://127.0.0.1:1188/service/log/dynamic-debug'
core/include/userver/rcu/rcu.hpp:208 0
core/include/userver/rcu/rcu.hpp:217 0
core/include/userver/rcu/rcu.hpp:230 0
core/include/userver/rcu/rcu.hpp:239 0
core/include/userver/rcu/rcu.hpp:384 0
core/include/userver/rcu/rcu.hpp:456 0
core/include/userver/rcu/rcu.hpp:461 0
core/include/userver/rcu/rcu.hpp:464 0
core/src/cache/cache_config.cpp:151 1
core/src/cache/cache_config.cpp:194 0
...
Enable dynamic debug for a whole file
bash
$ curl -X PUT 'http://127.0.0.1:1188/service/log/dynamic-debug?location=core/src/cache/cache_config.cpp'
OK
$ curl -X GET 'http://127.0.0.1:1188/service/log/dynamic-debug'
core/include/userver/rcu/rcu.hpp:208 0
core/include/userver/rcu/rcu.hpp:217 0
core/include/userver/rcu/rcu.hpp:230 0
core/include/userver/rcu/rcu.hpp:239 0
core/include/userver/rcu/rcu.hpp:384 0
core/include/userver/rcu/rcu.hpp:456 0
core/include/userver/rcu/rcu.hpp:461 0
core/include/userver/rcu/rcu.hpp:464 0
core/src/cache/cache_config.cpp:151 1
core/src/cache/cache_config.cpp:194 1
...
Remove dynamic debug for a whole file
bash
$ curl -X PUT 'http://127.0.0.1:1188/service/log/dynamic-debug?location=core/include/userver/rcu/rcu.hpp'
OK
$ curl -X GET 'http://127.0.0.1:1188/service/log/dynamic-debug'
It provides enabling and disabling logs by log level (see Dynamic config).
Variables force-disabled-level and force-enabled-level store lists of log locations to be disabled and enabled respectively.
Log locations are defined as path prefixes from the root directory.
File location may be followed by :[line index] without [ ] brackets to specify 1 exact log in that file. If the :[line index] without [ ] brackets is not specified then all logs are enabled in the file.
For example, the following configuration enables:
1) all logs with level WARNING or higher in the directory "core/include/userver/rcu",
2) all logs with level DEBUG or higher in the file "core/src/server/server.cpp"
3) one log (since exact line is specified) with level TRACE in the file "core/src/server/http/http_request_parser.cpp".