Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/documentation.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-11-09 16:03:42 +0300
committerGitHub <noreply@github.com>2022-11-09 16:03:42 +0300
commit07bccf14015a688f16398c3ff150df2175d68ff3 (patch)
treebe33a0645951ff20386217a2855d51b4587a67ae
parent28db6d92a9860d8f15e6d08c764723d45eaf2456 (diff)
parent1337c027eae597342c268577e6cef080a4751ecb (diff)
Merge pull request #9317 from nextcloud/backport/9310/stable25
[stable25] Document CriticalActionPerformedEvent
-rw-r--r--developer_manual/basics/logging.rst22
1 files changed, 22 insertions, 0 deletions
diff --git a/developer_manual/basics/logging.rst b/developer_manual/basics/logging.rst
index db9259279..490581cb1 100644
--- a/developer_manual/basics/logging.rst
+++ b/developer_manual/basics/logging.rst
@@ -41,3 +41,25 @@ the app ID.
use function OCP\Log\logger;
logger('calendar')->warning('look, no dependency injection');
+
+Admin audit logging
+-------------------
+
+If you want to log things less for system administration but for compliance reasons, e.g. who accessed which file,
+who changed the password of an item or made it public, the
+`admin audit log <https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/logging_configuration.html#admin-audit-log>`_
+is the correct place.
+
+You can easily add a log by simply emitting an ``OCP\Log\Audit\CriticalActionPerformedEvent`` event:
+
+.. code-block:: php
+
+ <?php
+
+ $dispatcher = \OCP\Server::get(\OCP\EventDispatcher\IEventDispatcher::class);
+
+ $event = new \OCP\Log\Audit\CriticalActionPerformedEvent(
+ 'My critical action for app %s',
+ ['name' => 'My App ID']
+ );
+ $dispatcher->dispatchTyped($event);