openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.59k forks source link

[jsscripting] Logger name missing for UI-based rules #17165

Closed Mark-VG closed 2 months ago

Mark-VG commented 2 months ago

In previous versions (4.2.0.M2) it was possible to set the logging level for individual rules using the syntax log:set DEBUG org.openhab.automation.script.ui.<Rule Name>

However in newer SNAPHOTS (4.3.0.SNAPHOT 4197) this no longer works.

Expected Behavior

When logging is set in a rule the output to the log file should look something like:

19:54:35.512 [DEBUG] [.openhab.automation.script.ui.<Rule Name>] - *** Test Log has Run ***

This then makes it possible to set the log level for each specific rule using the syntax:

log:set DEBUG org.openhab.automation.script.ui.<Rule Name>

The rule used to send the logs is (I use Blockly to test):

console.debug('*** Test Log has Run ***');

Current Behavior

In the current builds (4.3.0.SNAPHOT) the logging is shown as:

20:00:24.040 [INFO ] [org.openhab.automation.script        ] - *** Test Log has Run ***

As you will see the distinguishing part (.ui.<SCRIPT NAME>) is no longer included.

This means that the command required to set individual log levels no longer works.

Possible Solution

Send the full logger name for the rule as was done previoulsy?

Steps to Reproduce (for Bugs)

1.Create a simple logging rule such as:

console.info('*** Test Log has Run ***');

2.Monitor the openhab.log file to see the resulting log statement, this will look something like:

20:00:24.040 [INFO ] [org.openhab.automation.script        ] - *** Test Log has Run ***
  1. Set the logging level using the command:
    log:set DEBUG org.openhab.automation.script.ui.<Rule Name>

    and change log rule to:

    console.info('*** Test Log has Run ***');
  2. Monitoring the openhab.log file will show that nothing gets logged.

Context

My existing rules with log levels set no longer work. It is no longer possibel to set individual logging elvel per rule as you would have to set the entire org.openhab.automation.script level, so all rules will log at the same level and it is no longer possible to turn off for specific rules.

Your Environment

This has been discussed on community at: https://community.openhab.org/t/oh4-3-0-snapshot-blockly-log-not-working-debug-and-trace/157449

florian-h05 commented 2 months ago

This very likely is a side effect/regression from https://github.com/openhab/openhab-core/pull/4289, but it should be no problem to fix that.

Mark-VG commented 2 months ago

Thanks for fixing so quickly. Appreciate it.

openhab-bot commented 2 months ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/log-level-on-rule/157629/2