Bug 12952 - Log koha actions to syslog too
Summary: Log koha actions to syslog too
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Transaction logs (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Srdjan Jankovic
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-18 01:12 UTC by Srdjan Jankovic
Modified: 2016-12-05 21:22 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Log koha actions to syslog too (5.03 KB, patch)
2014-09-18 02:08 UTC, Srdjan Jankovic
Details | Diff | Splinter Review
Log koha actions to syslog too (5.05 KB, patch)
2014-09-26 02:59 UTC, Srdjan Jankovic
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Srdjan Jankovic 2014-09-18 01:12:20 UTC

    
Comment 1 Srdjan Jankovic 2014-09-18 01:54:08 UTC
Log transactions (actions) to syslog facility. The reason being to enable external tools that can parse log files to get their fingers on the action log.

The alternatives are:

1. Use Log::Any or similar. I did not go for this one because it is a bit hard to retrofit a beast like that, and then we are potentially entering into configuration nightmare.

2. Log straight to <log dir>/action.log. That was a hard decision, and the approach is more or less equivalent to the proposed one. I believe syslog gives a bit more flexibility.

Parts of the proposed solution that deal with syslog config are debian/rsyslog based, but those can easily be adopted in other environments.

I'm open for discussion/suggestions.
Comment 2 Srdjan Jankovic 2014-09-18 02:08:28 UTC Comment hidden (obsolete)
Comment 3 Srdjan Jankovic 2014-09-26 02:59:04 UTC
Created attachment 31887 [details] [review]
Log koha actions to syslog too

* Added kohasite and syslog_facility to config
* syslog_facility is set to "user" and commented out for the fresh site
  install
* If syslog_facility is enabled in config, log to syslog as <kohasite>
  (value of  kohasite config)
* /etc/rsyslog.d/99-<kohasite>.conf is created with filter instructions
  to direct <kohasite> log entries to standard log dir
  (/var/log/koha/<kohasite>) action.log; syslog daemons other than
  rsyslog need to be configured (or not) to do the same, otherwise catch
  all syslog log file is used
Comment 4 Joonas Kylmälä 2015-08-31 09:25:39 UTC
diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create
index 6891ac1..5c4aa2a 100755
--- a/debian/scripts/koha-create
+++ b/debian/scripts/koha-create
@@ -546,8 +546,12 @@ eof
     # Generate and install Apache site-available file and log dir.
     generate_config_file apache-site.conf.in \
         "/etc/apache2/sites-available/$name.conf"
+    # Generate and install rsyslog conf
+    generate_config_file rsyslog-site.conf.in \
+        "/etc/rsyslog.d/99-$name.conf"
     mkdir "/var/log/koha/$name"
-    chown "$username:$username" "/var/log/koha/$name"
+    chown "$username:adm" "/var/log/koha/$name"

The last line should not have the group adm but $username instead.
Comment 5 Srdjan Jankovic 2015-09-01 05:49:53 UTC
> -    chown "$username:$username" "/var/log/koha/$name"
> +    chown "$username:adm" "/var/log/koha/$name"
> 
> The last line should not have the group adm but $username instead.

This is because in case of a multi-site installation we may want to have an external process to be able to access all individual site logs. Without a common group it makes it hard to manage.
Comment 6 Joonas Kylmälä 2015-09-01 06:30:21 UTC
(In reply to Srdjan Jankovic from comment #5)
> > -    chown "$username:$username" "/var/log/koha/$name"
> > +    chown "$username:adm" "/var/log/koha/$name"
> > 
> > The last line should not have the group adm but $username instead.
> 
> This is because in case of a multi-site installation we may want to have an
> external process to be able to access all individual site logs. Without a
> common group it makes it hard to manage.

But do we have some script to change the group (during installation)? Hmm.. I'm not so sure about this. Maybe there could be some config file (not sure if there is one already for this kind of things) where it could be changed to one that the user wants or if not specified it would default to $username.
Comment 7 Srdjan Jankovic 2015-09-02 00:02:03 UTC
(In reply to Joonas Kylmälä from comment #6)

> But do we have some script to change the group (during installation)? Hmm..
> I'm not so sure about this. Maybe there could be some config file (not sure
> if there is one already for this kind of things) where it could be changed
> to one that the user wants or if not specified it would default to $username.

That is an interesting idea, and I could even implement it in the debian config. Although I must say that adm group sounds good enough for me (you don't give adm to everyone). Another possibility is to create a koha group and put all sites to that group. How do we go about making decisions like that?
Comment 8 Robin Sheat 2015-09-02 00:56:26 UTC
I think Srdjan is right here. As a rule of thumb, logs are group-owned by adm so that any user in the adm group can view them. This applies to things like syslog, mysql logs, mail logs, etc. 

I had a quick look and couldn't find a policy about it, but it seems to be the de facto thing to do.
Comment 9 Jonathan Druart 2015-12-28 11:51:18 UTC
We have Koha::Logger (bug 14167) now.