Bug 1475951

Summary: ODL should log using systemd journal instead of into its own log files
Product: Red Hat OpenStack Reporter: Michael Vorburger <vorburger>
Component: opendaylightAssignee: Michael Vorburger <vorburger>
Status: CLOSED DEFERRED QA Contact: Itzik Brown <itbrown>
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: mkolesni, nyechiel, sgaddam
Target Milestone: Upstream M2Keywords: Triaged
Target Release: 13.0 (Queens)   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-19 14:19:36 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael Vorburger 2017-07-27 15:36:24 UTC
Tim Rozet in Bug 1470191 dixit: 

    "Ideally we want ODL logging to be part of systemd journaling."

This new (type Enhancement) issue is the umbrella to look into this:

* investigate technical feasibility (POC)

* understand if it needs upstream work (ODL / Karaf),
  and if so, create new issues on respective upstream trackers, and link here

* link any work done related to this

* ....

Comment 1 Michael Vorburger 2017-07-27 16:41:23 UTC
I've noticed in an ODL Karaf distribution (built locally from an upstream current master = future Nitrogen release, based on Karaf 4) that there is an appender named 'syslog' in the etc/org.ops4j.pax.logging.cfg file (which is basically a Log4j v2 configuration used by Karaf, through some OPS4j's PAX Logging in the middle), using org.apache.log4j.net.SyslogAppender.

Isn't there a "thing" which translates stuff pushed into a syslog port (by SyslogAppender) into systemd journal, correctly translating events, with structure for e.g. stacktrace and all?

One would natively assume such a translator must exist - isn't there lots of existing old stuff pushing to syslog (like Log4j's SyslogAppender) which loads of people want to get into systemd journal, without everyone adjusting their apps?

If there is not, then I guess this boils down to us having to do integration work to get https://github.com/bwaldvogel/log4j-systemd-journal-appender into ODL, or probably much better, straight away upstream Karaf? I've just opened https://issues.apache.org/jira/browse/KARAF-5275 to first discuss this further over there (and in doing so and further investigating, realized that it actually probably needs to go into OPS4j's PAX Logging, first)...

Comment 2 Michael Vorburger 2017-08-11 07:33:19 UTC
> integration work to get https://github.com/bwaldvogel/log4j-systemd-journal-appender into ...

Janki has pointed out https://github.com/insideo/randomcoder-log4j-systemd-journal/ as an alternative, and I've spent a minute having a closer look into both of these, to conclude that bwaldvogel/log4j-systemd-journal-appender is the one to go with, because: 

  (1) it has both new Log4j2 as well as old Log4j v1 support, which is important because we are currently on Log4j v1 with Karaf 4.0.x, but will eventually get to Log4j2 on Karaf 4.1.x;  

  (2) it's available on Maven central (in both versions), whereas randomcoder's is only on Bintray (so for upstream OPS4j and Karaf integration that's no go);  

  (3) is a bit more configurable; e.g. we can choose whether or not to send say the ODL internal thread name into systemd journal, or not

  (4) minor difference in mapping Log4j FATAL level (bwaldvogel LOG_CRIT, randomcoder LOG_EMERG via getSyslogEquivalent()), but as we use log4j directly only slf4j not which doesn't have FATAL directly (only via Marker, see FAQ) that's irrelevant 

  (5) bwaldvogel's has more stars and forks on GitHub than insideo's ;-) and more recent updates

Otherwise they are similar - both implemented via com.sun.jna.Library.  The code even looks close enough to make me think that bwaldvogel may actually have been directly inspired by randomcoder's (e.g. normalize[Key]() method).