Configure OH3 to log to syslog

edit openhab/userdata/etc/log4j2.xml

In the

<Appenders> </Appenders>`

section add:

<!-- syslog appender -->
<Syslog name="SEVENT" host="your_syslogserver" port="your_syslogport" protocol="UDP" facility="local0" appName="openhab" />

add the newly added appender reference to

 <Logger additivity="false" level="INFO" name="openhab.event">
                    <AppenderRef ref="EVENT"/>
                     <AppenderRef ref="OSGI"/>
                     <AppenderRef ref="SEVENT"/>
 </Logger>
4 Likes

Hi,
Is this just adding to the xml?

As when I did, it created weird filenames in the remote log directory with unformatted log data.

Yes. I just modified the xml file.
The weird filenames might be some configuration issue at the syslog server side? Not sure.

Thanks.
The processing of the rsyslog server is working normal for the regular log files.
Also coming from other servers.
It’s only the openhab log that is creating these random directories. (See image)

I only use one template:
$template RemInputLogs, “/cam/remotelogs/%FROMHOST-IP%/%APP-NAME%/%PROGRAMNAME%.log”
. ?RemInputLogs

I’m afraid I can’t help you with that.
Personally I’m sending my logs to a Graylog server and use graylog “extractors” to get the items, state, etc…

ok thx.

I’ve got it a bit further now by adding following to the syslog appender: format=“RFC5424” newLine=“true”

Thank you very much! Works perfectly.
Just a quick note here: If you want to bring your “openhab.log” to Syslog, than you have to edit the following logger:

<Loggers>
  <!-- Root logger configuration -->
  <Root level="WARN">
    <AppenderRef ref="LOGFILE"/>
    <AppenderRef ref="OSGI"/>
    <AppenderRef ref="SEVENT"/>
  </Root>
.....
</Loggers>