- Platform information:
- Hardware: AMD64
- OS: Windows 10/10.0 (amd64)
- Java Runtime Environment: 11.0.9.1 (Zulu11.43+55-CA)
- openHAB version: openHAB 3.1.0 Release Build
Hi All
I have been battling to debug some rules - which I eventually got to work, but really battled with the logging and being able to filter for the events I am looking for in the Karaf Console. Cant be difficult and take plenty of more time when the entries are “lost” in all the other entries.
Example of what I am looking for:
15:08:12.395 [DEBUG] [.openhab.core.model.script.shelly_uni] - Battery Charging Updated
15:08:12.395 [DEBUG] [.openhab.core.model.script.shelly_uni] - Battery Status Updated
Which is generated by the rule:
rule "Battery State to Charging"
when
Item ShellyUNIshellyunie8db84d6b3e510163199230_VoltageADC changed
then
{
var upsBattVoltageNew = newState as Number
var upsBattVoltagePrevious = previousState as Number
if (upsBattVoltageNew >27.70){
if (ShellyUNI_Battery_Charging.state == OFF){
var strMessage = "UPS Battery has started charging. New Voltage: "
logDebug("shelly_uni", "UPS Batt Voltage Was: " + upsBattVoltagePrevious.toString())
logDebug("shelly_uni", "UPS Batt Voltage Now: " + upsBattVoltageNew.toString())
sendNotification("vangelder.mark@gmail.com", strMessage + upsBattVoltageNew.toString() )
logDebug("shelly_uni", "Battery Charging Sent! " )
ShellyUNI_Battery_Charging.postUpdate(ON)
ShellyUNI_Battery_Idling.postUpdate(OFF)
ShellyUNI_Battery_Critical.postUpdate(OFF)
logDebug("shelly_uni", "Battery Charging Set " )
}
else {
//return
ShellyUNI_Battery_Charging.postUpdate(ON)
logDebug("shelly_uni", "Battery Charging Updated " )
}
}
}
end
I have set log:set TRACE org.openhab.core.model.script.shelly_uni
Have tried log:tail |grep shelly_uni
which just gives me the full log (no grep). Tried other combinations
Have tried modifying log4j2.xml to redirect the logs to a different file - the file gets created but remains empty.
Changes added are:
<!-- ShellyUNI appender -->
<RollingRandomAccessFile append="true" fileName="${sys:openhab.logdir}/shellyuni.log" filePattern="${sys:openhab.logdir}/shellyuni.log.%i" immediateFlush="true" name="SHELLYUNI">
<PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-50.50c] - %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="16 MB"/>
</Policies>
<DefaultRolloverStrategy max="8"/>
</RollingRandomAccessFile>
<!-- ShellyUNI -->
and
<Logger additivity="false" level="TRACE" name="org.openhab.core.model.script.shelly_uni">
<AppenderRef ref="SHELLYUNI"/>
Any suggestions on making the filtering more accessible?
Thanks
Mark
EDIT: Just found this, which I have missed every time I searched before:
So no grep is required. Would still love advise of redirecting the entries though.