Trying to log file activities in nextcloud.log

Nextcloud 25.0.4.1
Debian 11
Apache 2.4.54
PhP 7.3.33-10

Hello,
I wish to insert in my logging file (nextcloud.log) the files activities as mentioned in the latest nextcloud manual in Logging — Nextcloud latest Administration Manual latest documentation

Log level
1: INFO: Activity such as user logins and file activities, plus warnings, errors, and fatal errors.

The goal is to be able to monitoring who is importing or deleting files (and which files)

Is this the first time you’ve seen this error? (Y/N): yes first log creation

The output of your Nextcloud log in Admin > Logging:

{"reqId":"OzUkdUfbX0RxwU0KYjry","level":1,"time":"2023-03-21T04:59:06+00:00","remoteAddr":"xxx.xxx.45.15","user":"xxxxxxx.yyyyy","app":"no app in context","method":"GET","url":"/owncloud/index.php/apps/files/","message":"Deprecated event type for \\OCP\\Collaboration\\Resources::loadAdditionalScripts: null","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.44","version":"25.0.4.1","data":[]}
{"reqId":"OzUkdUfbX0RxwU0KYjry","level":1,"time":"2023-03-21T04:59:06+00:00","remoteAddr":"xxx.xxx.45.15","user":"xxxxxxx.yyyyy","app":"no app in context","method":"GET","url":"/owncloud/index.php/apps/files/","message":"Deprecated event type for OCA\\Files::loadAdditionalScripts: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.44","version":"25.0.4.1","data":[]}
{"reqId":"WeMdbohUho8JeQupwmG5","level":1,"time":"2023-03-21T04:59:17+00:00","remoteAddr":"xxx.xxx.45.15","user":"xxxxxxx.yyyyy","app":"no app in context","method":"GET","url":"/owncloud/index.php/core/preview?fileId=462562&c=0da31c49ff0c7922b379989ebe886132&x=250&y=250&forceIcon=0&a=0","message":"Deprecated event type for OCP\\IPreview:PreviewRequested: Symfony\\Component\\EventDispatcher\\GenericEvent is used","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.44","version":"25.0.4.1","data":[]}

(during this session I imported a file and deleted it)

<?php
$CONFIG = array (
  'instanceid' => 'ochw98lnmynx',
  'passwordsalt' => 'NbyOAmO/+doLTKXE5JNBS9IxWCFiPx',
  'secret' => 'ujbuhUhxiLYNpJlWpZz3Dpt0hl3rtdYKqrVcCMxorxZibL3f',
  'trusted_domains' =>
  array (
    0 => 'groupware.xxxxxxx.net',
    1 => 'xx.xx.xx.xx9',
  ),
  'datadirectory' => '/srv/groupware/data/data/',
  'dbtype' => 'mysql',
  'version' => '25.0.4.1',
  'dbname' => 'owncloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_root',
  'dbpassword' => '49d8t6b8ur2xq7n3usvxws98ouo6zh',
  'logtimezone' => 'UTC',
  'installed' => true,
  'theme' => '',
  'log_type' => 'owncloud',
  'loglevel' => 1,
  'logfile' => '/var/log/nextcloud.log',
  'maintenance' => false,
  'mail_smtpmode' => 'sendmail',
  'mail_from_address' => 'contact',
  'mail_domain' => 'xxxxxxx.com',
  'overwrite.cli.url' => 'https://groupware.xxxxxxx.net/nextcloud',
  'mail_sendmailmode' => 'smtp',
  'data-fingerprint' => 'd7f9a43d5f02db98289f2ffab90371b4',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'encryption.legacy_format_support' => true,
  'encryption.key_storage_migrated' => false,
  'default_phone_region' => 'FR',
);

how can I get the informations I want ?

Thanks

You can enable the Admin Audit Log. This will get you log entries like that:

{"reqId":"XzL7TuhQCQ7sqriPQwhD","level":1,"time":"2023-03-21T17:55:17+01:00","remoteAddr":"<IP-ADDRESS>","user":"<USERNAME>","app":"admin_audit","method":"DELETE","url":"/remote.php/dav/files/<USERNAME>/Test123456.docx","message":"File deleted: \"/Test123456.docx\"","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0","version":"26.0.0.11","data":{"app":"admin_audit"}}

From my notes:

sudo -u www-data php /var/www/html/nextcloud/occ app:enable admin_audit
sudo -u www-data php /var/www/html/nextcloud/occ config:app:set admin_audit logfile --value="/var/log/nextcloud/audit.log"
sudo -u www-data php /var/www/html/nextcloud/occ config:system:set log.condition apps 0 --value admin_audit