If your service has a server::handlers::LogLevel configured, then you may change the current logging level at runtime, without service restart.
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.
Note that the server::handlers::DynamicDebugLog handler lives at the separate components.server.listener-monitor address, 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'
Note that the server::handlers::LogLevel handler lives at the separate components.server.listener-monitor address, 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 may get a response from other handler.
Note that the server::handlers::LogLevel handler lives at the separate components.server.listener-monitor address, so you have to request them using the listener-monitor credentials. See Production configs and best practices for more info on configuration.