Javascript - logging into different 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.

grep MyItemName events.log > MyItemName.log

There are equivalent commands in PowerShell. See How to watch and look through logging for more details.

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.