Logging Rules into separate file

I have lot of rule with some logging.
I would like move rule logging to a separate file, and if it is possibe only some specific rule logs.
For example I have a complex set of rules that handle my heater, so i would like to move only logging related to heater into a separate file. All log strinh of my heater, have a specific topic, for example heater.handling.some-stuff

is it possible to achieve this?


Yes, it is possible. You need to define the logger accordingly. In my case it has to start with “Maehrlin”

in the rule:

MOWER_LOGGER = "Maehrlin.CuttingDuration"
LogAction.logDebug(MOWER_LOGGER, u"Dauer des Mähvorgangs: State {}".format(MaehrlinState))

in log4j2.xml

	<RollingRandomAccessFile fileName="${sys:openhab.logdir}/mährlin.log" filePattern="${sys:openhab.logdir}/History/mährlin.log.%i" name="MOWER">
		<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
			<CronTriggeringPolicy schedule="0 0 0 ? * MON *"/>
		<DefaultRolloverStrategy fileIndex="min" min="1" max="7"/>

	<Logger additivity="false" level="DEBUG" name="org.openhab.core.model.script.Maehrlin">
		<AppenderRef ref="MOWER"/>

many thanks