Cannot connect to karaf consol

  • Platform information:
    • Hardware: dell server
    • OS: ubuntu 20.4
    • Java Runtime Environment: java 11
    • openHAB version: 3.1
  • Issue of the topic:
    the IDE has been setup and i can run OSGI debug in eclipse.
    as i try to debug a binding i like to get some more logs
    the org.apache.karaf.shell.cfg in openhab-main/git/openhab-distro/distributions/openhab/src/main/resources/userdata/etc
    has
    sshPort = 8101
    sshHost = 0.0.0.0

i try to connect like this
ssh openhab@localhost -p 8101 -vvv
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving “localhost” port 8101
debug2: ssh_connect_direct
debug1: Connecting to localhost [::1] port 8101.
debug1: connect to address ::1 port 8101: Connection refused
debug1: Connecting to localhost [127.0.0.1] port 8101.
debug1: connect to address 127.0.0.1 port 8101: Connection refused
ssh: connect to host localhost port 8101: Connection refused

what else is needed to get console logon?

You shouldn’t need to connect via ssh. You should get a prompt from Apache Felix Gogo right in the Eclipse Console window.

many thanks.
i have tried to set the log level of a binding in this console

g! log:set debug org.openhab.binding.xxxx
gogo: CommandNotFoundException: Command not found: log:set

so the console here is not the same as the karaf console
so how do i change the log level of a binding in that consol?

the command that you used to login to the karaf console is correct and it should work.
You are already logged on to the host that runs OH3 ?
What does

sudo netstat -tulpn | grep java

show ?
Besides other ports port 8101 should be listed.

No, running the Eclipse IDE, there us no Karaf console to log in AFAIK


udp6       0      0 127.0.0.1:40467         :::*                                1053/java

so there is no karaf running.
so how can i change then the log level for my binding?

I am not in reach of a computer atm, but AFAIR, you will find a logger config in the demo app project, where you can add logging definition for your binding. That‘s how I always do it…

Yes, Felix Gogo isn’t as fully featured as the normal Karaf console. You’ll need to edit log4j2.xml to enable debug logging for your binding as @hmerk mentioned. You can find it in openhab-distro, under Infrastructure/launch/app/runtime in the Eclipse package explorer. Look for the comment line that says “Uncomment this logger and update the name to enable debug logging for a binding”.

1 Like