OH2 log missing line numbers

When trying to debug problems in OH2, how does one enable line numbers in the log file?

I currently get this:

2017-03-09 23:38:18.162 [INFO ] [assic.internal.servlet.WebAppServlet] - Stopped Classic UI

I found a “log.cfg” file, but editing it didn’t help as apparently it’s overwritten by OH during startup…


The file you want to change is userdata/etc/org.ops4j.pax.logging.cfg (where userdata is /var/lib/openhab2 for apt-get installs).

1 Like


Would have never EVER found that.

It is documented in the main docs as well:


I am not sure if i missed something, but does this answer how to actually turn on line numbers the log files, especially for errors in rules?

Yes, it does – sort of. But you still won’t get line numbers from inside your rules files.

The comments say which file you have to edit:

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

And the documentation link Rich provided, has a section near the bottom labelled “Logging into [a] Separate File”.

This block in that file tells you how the logging to the openhab.cfg file is configured:

 # File appender - openhab.log
log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n

And this line is the one you need to change:

log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n

The pattern is described in the Log4j docs, but to be succinct, what you need to add is a line number conversion like “%L” somewhere. Mine looks like this:

log4j.appender.out.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c:%5.5L] - %m%n

Note that upper-case L and lower-case L give different results. The former is for line number, the latter location.