Making logging less verbose

Hi,

I’m trying to reduce the writes to the log files, partly because it makes them unreadable, and partly because it will burn out the microSD my odroid is running on. I certainly don’t need every GET to the server logged; only errors and important messages.

Is there an easy way to do this? I’m way too inexperienced with Linux to understand the logback.xml configuration file

thank you!

Dan

Logging can be reduced by editing the logback.xml file (in the configuration folder). This file allows you to tune the logging by classes, so you can reduce it (or increase it) for different classes/bindings independently.

Chris

Hi chris,

may I ask you how to do this for a specific binding? E.g., I use the Lacross binding for my waether sensors, but they send data around every 4 seconds - so it just spams the event-logfile. What I now did was the following in logback.xml:

	<logger name="runtime.busevents" level="INFO" additivity="false">
	<appender-ref ref="STDOUT" />
	<appender-ref ref="STDOUT" />

But this just stops (of course) the logging completely for all events. So, how can I reduce (or stop) the logging for a specific binding and/or for a specific group of items (if this is even possible!?)?

thanks
Daniel

Check out How to configure logging so its helpful at startup thread.

The section of logback.xml that breaks things up for me is:

<!-- Insteon Logging -->	
	<appender name="INSTEONPLMFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
	    <file>logs/insteonplm.log</file>
	    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	    	<fileNamePattern>logs/insteonplm-%d{yyyy-ww}.log.zip</fileNamePattern>
	       	<maxHistory>7</maxHistory>
	        </rollingPolicy>
	        <encoder>
	        	<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{30}[:%line]- %msg%n%ex{5}</pattern>
	        </encoder>
	</appender>
<logger name="org.openhab.binding.insteonplm" level="INFO" additivity="false">
<appender-ref ref="INSTEONPLMFILE" />
</logger>

<!-- MiOS Logging -->	
	<appender name="MIOSFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
	    <file>logs/mios.log</file>
	    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	    	<fileNamePattern>logs/mios-%d{yyyy-ww}.log.zip</fileNamePattern>
	       	<maxHistory>7</maxHistory>
	        </rollingPolicy>
	        <encoder>
	        	<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{30}[:%line]- %msg%n%ex{5}</pattern>
	        </encoder>
	</appender>
<logger name="org.openhab.binding.mios" level="DEBUG" additivity="false">
<appender-ref ref="MIOSFILE" />
</logger>

<!-- HTTP Logging -->	
	<appender name="HTTPFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
	    <file>logs/http.log</file>
	    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	    	<fileNamePattern>logs/http-%d{yyyy-ww}.log.zip</fileNamePattern>
	       	<maxHistory>7</maxHistory>
	        </rollingPolicy>
	        <encoder>
	        	<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{30}[:%line]- %msg%n%ex{5}</pattern>
	        </encoder>
	</appender>
<logger name="org.openhab.binding.http" level="INFO" additivity="false">
<appender-ref ref="HTTPFILE" />
</logger>

<!-- ModBus Logging -->	
	<appender name="MODBUSFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
	    <file>logs/modbus.log</file>
	    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
	    	<fileNamePattern>logs/modbus-%d{yyyy-ww}.log.zip</fileNamePattern>
	       	<maxHistory>7</maxHistory>
	        </rollingPolicy>
	        <encoder>
	        	<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{30}[:%line]- %msg%n%ex{5}</pattern>
	        </encoder>
	</appender>
<logger name="org.openhab.binding.modbus" level="DEBUG" additivity="false">
<appender-ref ref="MODBUSFILE" />
</logger>
2 Likes

Hi Daniel,

i am facing the same problem. openhab.log is getting spamed by entries from lacrosse binding. Did you find a working solution?

Kind regards

To stop the logging of a binding or other log resource, first check the openhab.log file in /var/log/openhab

My goal was to stop the logging of the exec binding which was cluttering the logs

2017-04-24 00:00:15.092 [INFO ] [g.openhab.io.net.exec.ExecUtil] - executed commandLine 'sudo python /usr/share/openhab/python/adda.py 0'

The third item in the log shows the log source, [log.openenhab.io.net.exec.ExecUtil]

The open the file /etc/openhab/logback.xml and add after the a line the name of the log you want to stap with level=“OFF”

    <logger name="org.atmosphere.cpr.AtmosphereFramework" level="ERROR" />^M

    <logger name="org.openhab.io.net.exec.ExecUtil" level="OFF" />^M

That will the stop the logging.

For the LaCrosse Binding, this would hence be
<logger name="org.openhab.binding.lacrosse.connector.LaCrosseConnector" level="ERROR" /> <logger name="org.openhab.binding.lacrosse.connector.LaCrosseConnector2" level="ERROR" />