I want to monitor the behaviour of a few items over the course of a day or two. So the standard log is not very convenient. Therefore I thought of writing a Javascript rule that would log state changes/updates to a different log file.
It would be easier to just use grep to extract the lines that mention your Item(s) from events.log. You can even redirect that into another file if you need to for some reason.
To cause any logger to log to another file, you’ll need to edit /var/lib/openhab/etc/log4j2.xml by adding a new log appender which writes to a file (use the openhab.log one as a template) and a new logger that maps the logger name from the rule to use that appender.
When you use console to log the logger name is org.openhab.automation.script.ui.<ruleUID>. If it’s a file based rule I think it’s <filename> instead. If you created your own logger, you already know the logger name.
I didn’t see anything obviously wrong with the config. Make sure the name matches the longer you are using in your rules. It is very unlikely “org.apache.karaf.jaas.modules.audit” is it. See my post above for what the default logger name would be if you are not changing it in your rule.