Howto do log in component __init__.py?

Hello,

I am still with my component ‘rollershutter’.
It does not seem to be loading.

To test, I want to generate logging output in init.py.

To understand the loading I have added log functions to the ethernet component in my git an use this own component.

In the ethernet_component.cpp the log outputs are displayed

[19:26:52][C][ethernet:325]: Ethernet:
[19:26:52][C][ethernet:514]:   Hallo <<<<===
[19:26:52][C][ethernet:515]:   IP Address: 192.168.xxx.xxx
[19:26:52][C][ethernet:516]:   Hostname: 'roller-shutter-2'
[19:26:52][C][ethernet:517]:   Subnet: 255.255.255.0

in the init.py ’ i have add 2 lines

line 45   LOGGER = logging.getLogger(__name__)
...
line 277  async def to_code(config):
line 278      LOGGER.debug("to_code ethernet Start") <<<<===
line 279      var = cg.new_Pvariable(config[CONF_ID])

However, I do not see the log outputs from the init.py of the ethernet component anywhere.
Where can I see these log outputs?

Best regards Mario

The code on the python files is only executed when you use esphome to compile the code. It does not run when you start the device using the compiled code.

Also, usually the logging is at info level, so your debug logging won’t print. If you make it info, it should show up in the output from the compile command, but is easy to miss.

Hello Neel,

thanks, with info is the log print in compiler output

INFO Generating C++ source...
INFO to_code ethernet Start <<==

Now i can search the problem in my component :wink:

best regards Mario