Thanks for posting this but I’m having trouble with it. If I have “logger:” in my main config file, in addition to the entries you posted above, I get full logs of everything no matter how tight I set the input selector. When I remove “logger:” I only get WARNING and ERROR messages, including this one:
2017-06-01 22:49:44 WARNING (MainThread) [homeassistant.core] Unable to find service logger/set_level
I can change the input selector but I don’t see any change to the logging. In the above configuration, with the selector set to ‘error’, I still see lots of debug entries in mqtt and automation components. If I set the slider to ‘debug’ I don’t see debug entries from other components.
What is the expected behavior? Maybe I don’t understand the purpose correctly.
The logger.set_level sets only the default level. The entries in ‘logs:’ stay in the level they are configured.
If you set only:
logger:
default: warn
and you select from ‘warn’ to ‘debug’, there should be a massive difference in the log, or anything is wrong.
Do you have entries like: 2017-06-02 10:59:34 INFO (MainThread) [homeassistant.components.automation] Executing Log Level in the log when you select values above ‘info’?
I’m getting the following error with this automation
> ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.log_level. Invalid data for call_service at pos 1: extra keys not allowed @ data['homeassistant.components']
I just ran across this and would like to know if this still works today in some form and if so, and someone using it sees this, could you please post your config and any automation examples please.
Works for me with a few changes over the years (actions, data_template, …).
# logger config
logger:
default: warn
# input_select, only for setting, doesn't reflect the level if changed from another place
input_select:
log_level:
name: Log Level
options:
- critical
- fatal
- error
- warning
- warn
- info
- debug
- notset
# automation
automation:
- alias: Log Level
triggers:
trigger: state
entity_id: input_select.log_level
actions:
action: logger.set_level
data: # works also with data_template but is deprecated
homeassistant.components: "{{ trigger.to_state.state }}"
If you want to test/set it from Tools > Actions (YAML Mode)