-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
option for a seperate audit log file #9293
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
Conversation
a745c66 to
011613d
Compare
Codecov Report
@@ Coverage Diff @@
## master #9293 +/- ##
============================================
+ Coverage 51.93% 51.93% +<.01%
- Complexity 25388 25402 +14
============================================
Files 1608 1609 +1
Lines 95429 95470 +41
Branches 1394 1394
============================================
+ Hits 49559 49584 +25
- Misses 45870 45886 +16
|
a4e55e2 to
07fd13f
Compare
lib/private/Log.php
Outdated
| // FIXME: Add this for backwards compatibility, should be fixed at some point probably | ||
| if ($config === null) { | ||
| $config = \OC::$server->getSystemConfig(); | ||
| $config = \OC::$server->getConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks logging while installing?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fairly sure switching from systemconfig to config will break yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gnah :(
lib/private/Log.php
Outdated
| } | ||
|
|
||
| return min($this->config->getValue('loglevel', Util::WARN), Util::FATAL); | ||
| return min($this->config->getSystemValue('loglevel', Util::WARN), Util::FATAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should move those consts to ILogger?
lib/private/Log/Syslog.php
Outdated
| use OCP\Log\IWriter; | ||
|
|
||
| class Syslog implements IWriter { | ||
| static protected $levels = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use class constant arrays with the currently supported php versions for a bit cleaner code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed that one, thanks for the hint. What do you have in mind with class constants however?
lib/private/Log/Syslog.php
Outdated
| // Close at shutdown | ||
| public function __construct(IConfig $config) { | ||
| openlog($config->getSystemValue('syslog_tag', 'ownCloud'), LOG_PID | LOG_CONS, LOG_USER); | ||
| register_shutdown_function('closelog'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do this with a destructor now?
lib/private/Log.php
Outdated
| // FIXME: Add this for backwards compatibility, should be fixed at some point probably | ||
| if ($config === null) { | ||
| $config = \OC::$server->getSystemConfig(); | ||
| $config = \OC::$server->getConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fairly sure switching from systemconfig to config will break yes
|
✓ reverted change to IConfig in Log |
4f4ac38 to
6347106
Compare
Codecov Report
@@ Coverage Diff @@
## master #9293 +/- ##
============================================
+ Coverage 51.93% 51.93% +<.01%
- Complexity 25388 25407 +19
============================================
Files 1608 1611 +3
Lines 95440 95484 +44
Branches 1394 1394
============================================
+ Hits 49564 49588 +24
- Misses 45876 45896 +20
|
71bbf60 to
4c7fd14
Compare
Moved to a separate PR: #9308 |
Let me rebase and fix the conflicts in this PR as the other one was merged. |
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
4c7fd14 to
90e1394
Compare
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
90e1394 to
b841a47
Compare
| * @param int $level | ||
| */ | ||
| public static function write($app, $message, $level) { | ||
| public function write(string $app, $message, int $level) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string $message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File takes arrays when logging exceptions :( and this needs to match the Interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough
lib/private/Server.php
Outdated
| $this->registerService(ILogFactory::class, function (Server $c) { | ||
| return new LogFactory($c); | ||
| }); | ||
| $this->registerAlias('LogFactory', ILogFactory::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed
lib/private/Server.php
Outdated
| * @throws \OCP\AppFramework\QueryException | ||
| */ | ||
| public function getLogFactory() { | ||
| return $this->query('LogFactory'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just query for ILogFactory::class
Or you remove this function in general and just query for the class where you need it
lib/private/Log/File.php
Outdated
| if(!touch(self::$logFile)) { | ||
| self::$logFile = $defaultLogFile; | ||
| } | ||
| public function __construct(string $path, string $fallbackPath = '', IConfig $config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to require IConfig over SystemConfig here? It is internal. And the systemconfig doesn't need DB stuff etc. So less change of cyclic dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably i had in mind back then making to adding API for it, but went another path… anyway, using SystemConfig makes sense. I'll adapt.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
MorrisJobke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👍
|
Hey, do you have any documentation on this? |
|
@eniac111 in the description ↑ 🙊
|
Could you add it to the documentation/manual? |
|
@MorrisJobke I just stumbled over the missing documentation of the audit log function too. To be able to improve the documentation I would need some more information about this function, which is enabled by activating the admin_audit app. |
This separate log file is already used, but with this there is a way to customize the path of this file via:
Only admin_audit entries are logged and we should not use settings of apps in other apps. So this then needs to be implemented in the trash bin as well. |
|
@MorrisJobke I've createds the following pull request for the documentation change: nextcloud/documentation#1300 Do I understand you correct that it is an error that "trashbin:expire" messages are logged in the audit.log? If yes, I would create a separate issue ticket to get that fixed: |
All |
solves #9166
evaluate gui for changing log location for admin_auditwe don't have this for the general log file either, can be controlled viaconfig:app:set admin_audit logfile --value="/var/log/nextcloud/audit.log"rotation file size follows general setting