Where to find the OpenHAB logs?

I installed OpenHAB (latest snapshot) on a Raspberry Pi 3 and now I’m looking for the logs as explained here:
https://docs.openhab.org/administration/logging.html

However, they are not in /var/log/openhab2 (path doesn’t exist). Does anyone know where my logs are?

‘sudo find / -name openhab.log’ gives me no results.

Not sure what distro your using. Have you tried Karaf?

ssh -p 8101 openhab@localhost

Then you can tail the logs.

log:tail

Depends how you installed OpenHab:
https://docs.openhab.org/installation/linux.html#viewing-log-messages
if you installed manually, they are here:
/opt/openhab2/userdata/logs/openhab.log

I installed manually, but /opt/openhab2 does not exist! /opt does though.

Yes although I did that using

 openhab-cli console

and then the log:tail command, which works fine.

But I still would like to know where my logs actually are.

Where can I see the configuration string where they are put??? The startup command (seen in htop) is

/usr/bin/java -Dopenhab.home=/usr/share/openhab2 -Dopenhab.conf=/etc/openhab2 -Dopenhab.runtime=/usr/share/openhab2/runtime -Dopenhab.userdata=/var/lib/openhab2 -Dopenhab.log

Now both /var/lib/openhab2 and /usr/share/openhab2 exist, but they don’t list an openhab.log file, nor anything else that could be a log. Trying to find it gives me zero results:

sudo find / -name openhab.log
sudo find / -name *openhab.log

In fact, running

 sudo find / -name *openhab*

only gives me this:

/etc/apt/sources.list.d/openhab2.list
/etc/default/openhab2
/etc/init.d/openhab2
/etc/profile.d/openhab2.sh
/etc/rc0.d/K01openhab2
/etc/rc1.d/K01openhab2
/etc/rc2.d/S04openhab2
/etc/rc3.d/S04openhab2
/etc/rc4.d/S04openhab2
/etc/rc5.d/S04openhab2
/etc/rc6.d/K01openhab2
/etc/systemd/system/multi-user.target.wants/openhab2.service
/etc/openhab-cli
/etc/openhab2
/sys/fs/cgroup/systemd/system.slice/openhab2.service
/tmp/hsperfdata_openhab
/usr/bin/openhab-cli
/usr/lib/systemd/system/openhab2.service
/usr/share/openhab2
/usr/share/openhab2/runtime/system/org/openhab
/usr/share/openhab2/runtime/system/org/openhab/distro/openhab-addons
/usr/share/openhab2/runtime/system/org/openhab/distro/openhab-addons/2.3.0-SNAPSHOT/openhab-addons-2.3.0-SNAPSHOT-features.xml
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.ui.dashboard
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.ui.dashboard/2.3.0-SNAPSHOT/org.openhab.ui.dashboard-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core.karaf
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core.karaf/2.3.0-SNAPSHOT/org.openhab.core.karaf-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.io.sound
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.io.sound/2.3.0-SNAPSHOT/org.openhab.io.sound-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core/2.3.0-SNAPSHOT/org.openhab.core-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.ui.homebuilder
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.ui.homebuilder/2.3.0-SNAPSHOT/org.openhab.ui.homebuilder-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core.compat1x
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.core.compat1x/2.3.0-SNAPSHOT/org.openhab.core.compat1x-2.3.0-SNAPSHOT.jar
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.io.jetty.certificate
/usr/share/openhab2/runtime/system/org/openhab/core/org.openhab.io.jetty.certificate/2.3.0-SNAPSHOT/org.openhab.io.jetty.certificate-2.3.0-SNAPSHOT.jar
/var/cache/apt/archives/openhab2_2.3.0~20180219205652-1_all.deb
/var/cache/apt/archives/openhab2_2.3.0~20180206033048-1_all.deb
/var/cache/apt/archives/openhab2_2.3.0~20180216003248-1_all.deb
/var/lib/apt/lists/openhab.jfrog.io_openhab_openhab-linuxpkg_dists_unstable_Release.gpg
/var/lib/apt/lists/openhab.jfrog.io_openhab_openhab-linuxpkg_dists_unstable_Release
/var/lib/apt/lists/openhab.jfrog.io_openhab_openhab-linuxpkg_dists_unstable_main_binary-armhf_Packages
/var/lib/dpkg/info/openhab2.preinst
/var/lib/dpkg/info/openhab2.md5sums
/var/lib/dpkg/info/openhab2.conffiles
/var/lib/dpkg/info/openhab2.list
/var/lib/dpkg/info/openhab2.prerm
/var/lib/dpkg/info/openhab2.postinst
/var/lib/dpkg/info/openhab2.postrm
/var/lib/openhab2
/var/lib/openhab2/etc/org.openhab.addons.cfg
/var/lib/openhab2/tmp/mvn/org/openhab
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habpanel
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habpanel/2.3.0-SNAPSHOT/org.openhab.ui.habpanel-2.3.0-SNAPSHOT.jar.sha1
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habpanel/2.3.0-SNAPSHOT/org.openhab.ui.habpanel-2.3.0-SNAPSHOT.jar
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habmin
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habmin/2.3.0-SNAPSHOT/org.openhab.ui.habmin-2.3.0-SNAPSHOT.jar
/var/lib/openhab2/tmp/mvn/org/openhab/ui/org.openhab.ui.habmin/2.3.0-SNAPSHOT/org.openhab.ui.habmin-2.3.0-SNAPSHOT.jar.sha1
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.paperui
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.paperui/2.3.0-SNAPSHOT/org.openhab.ui.paperui-2.3.0-SNAPSHOT.jar.sha1
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.paperui/2.3.0-SNAPSHOT/org.openhab.ui.paperui-2.3.0-SNAPSHOT.jar
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.basicui
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.basicui/2.3.0-SNAPSHOT/org.openhab.ui.basicui-2.3.0-SNAPSHOT.jar.sha1
/var/lib/openhab2/tmp/mvn/org/openhab/core/org.openhab.ui.basicui/2.3.0-SNAPSHOT/org.openhab.ui.basicui-2.3.0-SNAPSHOT.jar
/var/lib/openhab2/tmp/mvn/org/openhab/binding/org.openhab.binding.zwave
/var/lib/openhab2/tmp/mvn/org/openhab/binding/org.openhab.binding.zwave/2.3.0-SNAPSHOT/org.openhab.binding.zwave-2.3.0-SNAPSHOT.jar.sha1
/var/lib/openhab2/tmp/mvn/org/openhab/binding/org.openhab.binding.zwave/2.3.0-SNAPSHOT/org.openhab.binding.zwave-2.3.0-SNAPSHOT.jar
/var/lib/openhab2/tmp/libNRJavaSerial_HF_openhab_0
/var/lib/openhab2/config/org/openhab

Could it be my logs only live in memory somewhere? Or is that not possible? Doing ls /tmp only gives me

getvolume  hsperfdata_openhab  hsperfdata_volumio  log  presentation.html  setvolume  shairport-sync-metadata  snapfifo  upmpdcli.conf  upmpdclicache

neither of which are OpenHAB logs.

Maybe a dirty but working way:
Install frontail via openhabian-config on the SSH session.
Afterwards, navigate in your browser to

myOpenHabianIp:9001

(The dashboard on port 8001 should also give you access to frontail directly).

This easily should show you the following:


So it will list the sources for the logs.

If you don’t see those files or loggins still is not working can be the reason for old config files.
Always make sure that you replace the config files with the new ones when you are performing an upgrade.
I had also a broking logging after upgrading from 2.1 to 2.2 since the default bash answer for “new config files” is “n” which means: “Keep the old stuff”.

Good idea, but I installed manually, so I don’t have openhabian-config.

Indeed, I think something is broken. If nobody else has ideas on what to try I guess I will just have to reinstall the whole system…

Are you actually sure that OH2 is running?
systemctl status openhab2.service

Did you install the correct Java version?
https://docs.openhab.org/installation/index.html#prerequisites

I believe it is possible, but would not happen by itself; if you achieved this, you would have put enough work into it, to know where your logfiles are

Yes, it is running, I am actually able to view the log using the console with the command log:tail. I didn’t look at the code so I don’t know what happens to log messages. I think I would need a developer to tell me if it is possible that the logs just are not written to disk, but only kept in memory. (I am thinking for example a permissions issue with the file system and that the logs are not written because of that.)

Any ideas still welcome.

Since the previous search I reinstalled the system (on a Raspberry Pi) but I still cannot find my log file. There is no openhab.log anywhere in the file system on disk, nor is it in memory (/tmp). Can it only reside in /opt/openhab2/userdata/logs/openhab.log?

Actually, I read in the manual that it should be in /var/log/. Not sure why someone said it should be in /opt/openhab2/userdata/logs/. Anyway, it’s not there either.

I do have the file /var/lib/openhab2/etc/org.ops4j.pax.logging.cfg. In there it makes reference to a variable ${openhab.logdir} but since I am unfamiliar with the source I have no idea what this value expands to.

Can a developer tell me perhaps where the logs are kept? Or how I might possibly find them?

Is there a chance or trick to use a Linux grep of the (data) log file: /var/log/openhab2/openhab.log ?
(same as possible with the events.log)

I can tail the openhab.log with:

ssh -p 8101 openhab@localhost
log:tail

but how can I use “grep” to find special values or string from shell ?

Can I export the log into a regulaty textfile so I use grep on this file than ?

just use

log:tail | grep -i yourstring

in the karaf-console. To export you can use “cat”. I think you can use these commands in the ssh too.

EDIT:
Example

[16:33:12] hab@openHABianPi:~$ cat /var/log/openhab2/openhab.log | grep -i float
2019-07-08 16:04:17.994 [INFO ] [se.smarthome.model.script.RainVolume] - RainVolume as Float for comparison: localHourlyForecast3RainVolume (Type=NumberItem, State=0.0 mm, Label=in 03 Stunden Niederschlagsmenge, Category=rain, Groups=[gOWM])
[16:34:08] hab@openHABianPi:~$

Strange …
I see, regulary cat and grep works (now) also from the shell …
Before the message was, that the file is a data file and can’t be displayed (cat, tail, …)
Don’t know what happens before …

But file type from openhab.log ist still “data” (events.log is “Unicode-Text”)
(saw with: file )

Sorry for late reply.
Is the file-type a problem ?

[12:07:28] hab@openHABianPi:~$ file test_test
test_test: UTF-8 Unicode text
[12:07:39] hab@openHABianPi:~$ file /var/log/openhab2/openhab.log
/var/log/openhab2/openhab.log: ASCII text

I made the following:
1.

 tail -100 /var/log/openhab2/openhab.log > test_test

to get some lines from the log-file and bring the output to another file ( in may case it’s “test_test” in my home-directory). And the result of the file-command you can see above.

  1. Go with your Editor to your home-directory and open it
    :wink: