Would be nice if Kamailio could log various events directly to journald bypassing syslog. This would make logging much more accessible, structured and secure. Also additional meta-data could be saved directly. This would also greatly simplify exporting logs in a structured way using journald's json facilities. The backward compatibility will be preserved automatically by journald.
Here is relevant write-up: http://0pointer.de/blog/projects/journal-submit.html
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370
I think we can't abandon syslog, but maybe you could help us with a modular logging system. There are many options.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-149123621
Logging to systemd journal adds dependency to libsystemd which is not available on all operating systems.
As I checked the provided link and it looked rather easy, I added a new module (named log_systemd) that exports to config a wrapper to sd_journal_print().
I will try to get the core logging function to be more flexible and be able to use a different function than syslog, so a module can overwrite the core preference. However, that means the logging via something wanted by a module will be effective once that module is loaded, before (from kamailio start till module load) the syslog will be used.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-149503298
Maybe we can add logging channels so we can use both. Custom channels that are not sent to syslog, then we don't have to change xlog etc.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-149510199
My first thought was to use a pointer to logging function and set that by default to syslog. A module can overwrite the pointer with another function. Obviously that can happen when the module is loaded.
In this way, all logging will go through the new function, no need to change something else -- so xlog() as well as the other messages from C code will be handled by the new function.
On the other hand, sd_journal_print() seems to be a macro, meaning it cannot be used as pointer for a function. The advantage of the macro is ability to get the file name, line and function name of its use location. However, we already do this via our LOG/DEBUG macros, prefixing the log messages with these attributes.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-149519506
I pushed this morning a framework allowing to change the 'syslog' function with another one. As sample implementation I added log_custom module which sends the log messages via udp to a configured address and port (it was easier for me to test).
The log_systemd was enhanced to replace the syslog() with a wrapper around sd_journal_print() -- however, I didn't have the time to test it as I am lacking systemd familiarity, hopefully @zabbal can do it and provide some feedback. Info about how to use it are in the readme:
* http://kamailio.org/docs/modules/devel/modules/log_systemd.html#idp1223624
Depending on what the new logging needs to initialize, log messages are diverted from syslog either when module is loaded or module is initialized. Before that, the log messages are stored in syslog.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-149862281
Closed #370.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#event-451945388
Going to close this one as the feature was implemented, in order to keep the issue tracker focused on open items. Hoping that @zabbal will test and report back if there are issue.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/370#issuecomment-153013403