Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(logging configuration) Expand the admin_audit section #10604

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions admin_manual/configuration_server/logging_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
Logging
=======

Use your Nextcloud log to review system status, or to help debug problems. You may adjust logging levels, and choose between using the Nextcloud log or your syslog. If additional audit information is required, you can optionally activate the **admin_audit** app, which by default generates a separate audit.log file in the data directory.
Use your Nextcloud log to review system status, or to help debug problems. You may adjust logging levels, and choose how and where log data is stored. If additional event logging is required, you can optionally activate the **admin_audit** app.

When ``file`` based logging is utilized, both the Nextcloud log and, optionally, the **admit_audit** app log can be viewed within the Nextcloud interface under *Administration settings -> Logging* (this functionality is provided by the **logreader** app).
Copy link
Contributor

@szaimen szaimen Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can? I thought this is a missung feature...

Copy link
Member Author

@joshtrichards joshtrichards Jun 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too . I got sick of people asking and not knowing the answer. It had been on my to-do list for awhile so finally got around to digging into the code and testing earlier today. So, yes, it does exist as-is today in a form that is totally reasonable for many use cases.


Further configuration and usage details for both the standard Nextcloud log and the optional **admin_audit** app log can be found below.

Log level
---------
Expand Down Expand Up @@ -131,34 +135,55 @@ Log field breakdown

Empty value are written as two dashes: ``--``.

Admin audit log
---------------
Admin audit log (Optional)
--------------------------

By enabling the **admin_audit** app, additional information about various events can be logged. Similar to the normal logging, the audit log can be provided to any of the existing logging mechanisms in :file:`config/config.php`. The default behavior, if no parameters are specified after the app is enabled, is ``file`` based logging to a file called ``audit.log`` stored in the ``datadirectory``.

If ``loglevel`` in ``config.php`` is set to ``2`` or higher, audit logging needs to be triggered explicitly by adding the following setting to to ``config.php``:
If you wish to override this and log to syslog instead the following would be one approach:

::

'log.condition' => [
'apps' => ['admin_audit'],
"log_type_audit" => "syslog",
"syslog_tag_audit" => "Nextcloud",
"logfile_audit" => "",

Log level interaction
~~~~~~~~~~~~~~~~~~~~~

If system ``loglevel`` in ``config.php`` is set to ``2`` or higher, audit logging needs to be triggered explicitly by adding the following setting to to ``config.php``:

::

"log.condition" => [
"apps" => ["admin_audit"],
],

Find detailed documentation on auditable events for enterprises in our `customer portal <https://portal.nextcloud.com/article/using-the-audit-log-44.html>`_.

Integrating into the Web Interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The built-in NC ``logreader`` app (which is what provides the *Administration settings->Logging* interface) only accesses the file-based ``nextcloud.log``. The **admin_audit** app log output, however, can be integrated into the web interface by configuring it to *also* log to the ``nextcloud.log``.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Better would be something like nextcloud/logreader#857 though

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR looks quite useful if one doesn't wish to combine their on-disk audit log with the normal Nextcloud log.

The confusing thing has been that screenshot from the logreader app repository README - (it's referenced in nextcloud/logreader#129 and occasionally on the forum). It shows everything merged together. :-)

So it turns out it's totally been possible all along.


Similar to the normal logging, the audit log can be written to any of the existing logging mechanism in :file:`config/config.php`:
Add the following to your ``config.php`` (adjusting the path to your own ``nextcloud.log`` path):

::

"log_type_audit" => "syslog",
"syslog_tag_audit" => "Nextcloud",
"logfile_audit" => "",
'log.condition' => [
'apps' => [ 'admin_audit'],
],
'logfile_audit' => '/var/www/html/data/nextcloud.log',

Configuring through admin_audit app settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously the logfile could be defined in the app config. This config is still used when the system config is not provided:
Previously the audit logfile was defined in the app config. This config is still used when the system config is not provided, but is considered a legacy parameter.

::

occ config:app:set admin_audit logfile --value=/var/log/nextcloud/audit.log

Find detailed documentation on auditable events for enterprises in our `customer portal <https://portal.nextcloud.com/article/using-the-audit-log-44.html>`_.

.. _PHP date function: http://www.php.net/manual/en/function.date.php

Workflow log
Expand Down