[OH3] Docs for new logging config?

Hi there (again),

plaing with a shiny new system…OH3 this time…I tend to increase log levels to see what’s going on. My OH2 production system uses the INFO level as default for many parts.

OH3 has changed the logging. Is there already any documentation and examples on how to configure the new loggings system and where (path to config files)?

BTW: I am using OH3 on a RasPi using Package Install, not openhabian - if that’s important for the path to config files.

Thank you in advance.

Pretty much all OH3 documentation so far is in this forum :frowning:

This one might be helpfull

See http://next.openhab.org/docs/administration/logging.html

:+1: Danke Markus.

You keep saying that but it’s simply not true and never has been true. The Getting Started tutorial was in the forum because we wanted to make it easier for people who are not proficient with GitHub to contribute. Apparently we shouldn’t have bothered. But the devs have been making *tons of edits to the core docs at next.openhab.org.

This is a perfect example.

The config file for logging is located in the userdata/etc folder (manual setup) or in /var/lib/openhab/etc (apt/deb-based setup).

Attention OH2 users

The format and filename to store log settings has changed. It used to be org.ops4j.pax.logging.cfg in openHAB 2 and became log4j2.xmlin openHAB 3.

and further on down the page is a link to the full docs for how to configure logging.

Maybe actually go look at the docs rather than assuming that we don’t give a s%^&* about docs and have decided that OH 3 doesn’t need them.

Up until the past couple of weeks, next.openhab.org just had a copy of the OH2 docs except for a few new bindings such as reportopenhab. i guess we have a different definition of documentation.

No, the developers have been updating then for months as they make changes to the code that require doc changes.

Maybe we do but I suspect that OH will never have documentation that fits your definition. So why harp on it? It doesn’t help anyone and frankly it only serves to destroy the moral of those few volunteers who have spent hours and hours volunteering their time to create and update the docs, as completely inept and inadequate those efforts are apparently in your opinion. It’s not like you’re sleeping to to help.

I know you help out the best ways you can and as much as you can but you don’t have to denigrate the rest of our efforts. We’re doing the best we can too.

That’s correct, it used to display the OH2 docs until that was changed some days ago.

But the following is also true.
So Bruce be more careful with your claims, Rich is right this is destructive to volunteers’ moral.
You should be really in the know when you put up judgements in public.

In the advent of Christmas - greetings to all developers and volunteers!

The direction this thread took has not been my intention. Although as a user one hopes for a stable and well documented package (Christmas again ;-), we have to realize that this is not done by paid staff and all people here are spending amounts of their private time on it.

Leaving this - not the Christmas mood! - behind, maybe one final question: while OH3 is still not released, should I prefer to read the docs directly from github or from next.openhab.org?

2 Likes

Yes, until the release you should look to next.openhab.org for OH 3 info. And if you find something not yet updated to oh 3 that you think should be by this point (I just noticed that the docs for executeCommandLine have but been updated in the Actions page) it wouldn’t hurt to drop a note in the forum. Someone may be working on it already, or it may be something we missed.

Somebody mentioned the Wimdows install instructions. The image for JAVA_HOME still shows Java 8.

Thx for this post, sometimes it’s easier to find a certain chapter in the docs by searching in the forum :sweat_smile:

And while the logging chapter explains how to customize logging via console and where to find the logging configuration file log4j2.xml, it’s a bit sparse on how to actually customize the config file.

I would like to add some examples on how to filter events similar to this post for openhab2:

############ CUSTOM FILTERS START HERE #################
log4j2.appender.out.filter.jettyWarn.type = RegexFilter
log4j2.appender.out.filter.jettyWarn.regex = .*(URI is too large >8192|while writing a response message entity to the container output stream|Unable to connect Netatmo API).*
log4j2.appender.out.filter.jettyWarn.onMatch = DENY
log4j2.appender.out.filter.jettyWarn.onMisMatch = NEUTRAL

log4j2.appender.event.filter.declutter.type = RegexFilter
log4j2.appender.event.filter.declutter.regex = .* changed .*
log4j2.appender.event.filter.declutter.onMatch = DENY
log4j2.appender.event.filter.declutter.onMismatch = NEUTRAL
################# END OF CUSTOM FILTERS ################

I already managed to suppress Item changed log entries (lower than ERROR) by adding the following in log4j2.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><Configuration monitorInterval="10">

    [...]

	<Loggers>

    [...]

		<!-- CUSTOM LOGGERS START HERE -->
		<!--  -->
		<!-- Suppress *Item changed* entries -->
		<Logger level="ERROR" name="openhab.event.ItemStateChangedEvent"/>
		<Logger level="ERROR" name="openhab.event.GroupItemStateChangedEvent"/>
		<!--  -->
		<!-- CUSTOM LOGGERS END HERE -->
	</Loggers>
</Configuration>

But how would I filter for custom strings? How would I suppress, for example, entries containing Unable to connect Netatmo API?
Pretty sure it would be by appending a filter to the correct logger (ThingStatusInfoChangedEvent?), but how is the syntax for that?

And since we are talking syntax / examples - the documentations also mentions Redirect the log to a text file - how is the syntax for that? Would the following write all events related to BindingX into a file called bindingX.log?

<?xml version="1.0" encoding="UTF-8" standalone="no"?><Configuration monitorInterval="10">
	<Appenders>
    [...]
		<!-- Rolling file appender -->
		<RollingFile fileName="${sys:openhab.logdir}/bindingX.log" filePattern="${sys:openhab.logdir}/bindingX.log.%i" name="BINDINGX">
			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
			<Policies>
				<OnStartupTriggeringPolicy/>
				<SizeBasedTriggeringPolicy size="8 MB"/>
			</Policies>
		</RollingFile>	
	</Appenders>
	<Loggers>
    [...]
		<Logger additivity="false" level="INFO" name="org.openhab.binding.x">
			<AppenderRef ref="BINDINGX"/>
			<AppenderRef ref="OSGI"/>
		</Logger>
	</Loggers>
</Configuration>

@rlkoshak do you know the correct syntax / do you know where to find more information?

Have you looked at
https://logging.apache.org/log4j/2.x/

1 Like

Seems like that is where I can find the correct syntax :+1:

So as far as I get it the string filter should look like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><Configuration monitorInterval="10">
	<Appenders>
       [...]
		<!-- Event log appender -->
		<RollingRandomAccessFile fileName="${sys:openhab.logdir}/events.log" filePattern="${sys:openhab.logdir}/events.log.%i" name="EVENT">
      		<RegexFilter regex=".*(URI is too large >8192|while writing a response message entity to the container output stream|Unable to connect Netatmo API).*" onMatch="DENY" onMismatch="NEUTRAL"/>
			<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n"/>
			<Policies>
				<OnStartupTriggeringPolicy/>
				<SizeBasedTriggeringPolicy size="16 MB"/>
			</Policies>
		</RollingRandomAccessFile>
       [...]
	</Appenders>
    [...]
</Configuration>

(line <RegexFilter regex=".*(URI is too large >8192|while writing a response message entity to the container output stream|Unable to connect Netatmo API).*" onMatch="DENY" onMismatch="NEUTRAL"/>)