Skip to content

Commit 71058e0

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
Allow write audit log to syslog and systemdlog
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent d7c9cb3 commit 71058e0

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

apps/admin_audit/lib/AppInfo/Application.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,19 @@ public function boot(IBootContext $context): void {
9696
}
9797

9898
private function getLogger(IConfig $config,
99-
LoggerInterface $logger,
10099
ILogFactory $logFactory): LoggerInterface {
101-
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
102-
$logFile = $config->getAppValue('admin_audit', 'logfile', $default);
103-
104-
if ($logFile === null) {
105-
return $logger;
100+
$auditType = $config->getSystemValueString('log_type_audit', 'file');
101+
$defaultTag = $config->getSystemValueString('syslog_tag', 'Nextcloud');
102+
$auditTag = $config->getSystemValueString('syslog_tag_audit', $defaultTag);
103+
$logFile = $config->getSystemValueString('logfile_audit', '');
104+
105+
if ($auditType === 'file' && !$logFile) {
106+
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
107+
// Legacy way was appconfig, now it's paralleled with the normal log config
108+
$logFile = $config->getAppValue('admin_audit', 'logfile', $default);
106109
}
107-
return $logFactory->getCustomPsrLogger($logFile);
110+
111+
return $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag);
108112
}
109113

110114
/**

config/config.sample.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,13 @@
837837
*/
838838
'log_type' => 'file',
839839

840+
/**
841+
* This parameter determines where the audit logs are sent. See ``log_type`` for more information.
842+
*
843+
* Defaults to ``file``
844+
*/
845+
'log_type_audit' => 'file',
846+
840847
/**
841848
* Name of the file to which the Nextcloud logs are written if parameter
842849
* ``log_type`` is set to ``file``.
@@ -846,7 +853,15 @@
846853
'logfile' => '/var/log/nextcloud.log',
847854

848855
/**
849-
* Log file mode for the Nextcloud loggin type in octal notation.
856+
* Name of the file to which the audit logs are written if parameter
857+
* ``log_type`` is set to ``file``.
858+
*
859+
* Defaults to ``[datadirectory]/audit.log``
860+
*/
861+
'logfile_audit' => '/var/log/audit.log',
862+
863+
/**
864+
* Log file mode for the Nextcloud logging type in octal notation.
850865
*
851866
* Defaults to 0640 (writeable by user, readable by group).
852867
*/
@@ -870,6 +885,16 @@
870885
*/
871886
'syslog_tag' => 'Nextcloud',
872887

888+
/**
889+
* If you maintain different instances and aggregate the logs, you may want
890+
* to distinguish between them. ``syslog_tag_audit`` can be set per instance
891+
* with a unique id. Only available if ``log_type`` is set to ``syslog`` or
892+
* ``systemd``.
893+
*
894+
* The default value is the value of ``syslog_tag``.
895+
*/
896+
'syslog_tag_audit' => 'Nextcloud',
897+
873898
/**
874899
* Log condition for log level increase based on conditions. Once one of these
875900
* conditions is met, the required log level is set to debug. This allows to

0 commit comments

Comments
 (0)