from openhab import logger
logger.info("logger is used")
print("print is used")
the result is this:
2026-01-09 15:23:00.013 [INFO ] [g.openhab.automation.pythonscripting] - logger is used
2026-01-09 15:23:00.013 [INFO ] [utomation.pythonscripting.71b019046e] - print is used
Is it not supposed to add the rule ID after “pythonscripting” in both methods?
The reason was that the prefix was generated when the module was imported.
With file-based rules, this happens when the rule is loaded and directly executed. This works as expected. However, with UI-based rules, the rule is precompiled or cached. At that point, the log prefix was already generated, even though the rule ID hadn’t yet been determined.
I’ve now implemented this in a more “lazy” way. This means the prefix is generated the first time the logging object is used. This should fix the error.