Merge pull request #9137 from nextcloud/default-log-rotate-size

Set the default log rotate size to 100 MB
This commit is contained in:
Morris Jobke 2018-04-11 02:10:54 +02:00 committed by GitHub
commit e302266a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -764,9 +764,9 @@ $CONFIG = array(
* old logfile reaches your limit. If a rotated log file is already present, it * old logfile reaches your limit. If a rotated log file is already present, it
* will be overwritten. * will be overwritten.
* *
* Defaults to ``0`` (no rotation) * Defaults to 100 MB
*/ */
'log_rotate_size' => false, 'log_rotate_size' => 100 * 1024 * 1024,
/** /**

View File

@ -105,7 +105,7 @@ class File extends Command implements Completion\CompletionAwareInterface {
$defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log'; $defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
$output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile)); $output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
$rotateSize = $this->config->getSystemValue('log_rotate_size', 0); $rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024);
if ($rotateSize) { if ($rotateSize) {
$rotateString = \OCP\Util::humanFileSize($rotateSize); $rotateString = \OCP\Util::humanFileSize($rotateSize);
} else { } else {

View File

@ -36,7 +36,7 @@ class Rotate extends \OC\BackgroundJob\Job {
public function run($dummy) { public function run($dummy) {
$systemConfig = \OC::$server->getSystemConfig(); $systemConfig = \OC::$server->getSystemConfig();
$logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); $logFile = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
$this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', false); $this->max_log_size = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
if ($this->max_log_size) { if ($this->max_log_size) {
$filesize = @filesize($logFile); $filesize = @filesize($logFile);
if ($filesize >= $this->max_log_size) { if ($filesize >= $this->max_log_size) {

View File

@ -105,7 +105,7 @@ class FileTest extends TestCase {
['log_type', 'file', 'log_type_value'], ['log_type', 'file', 'log_type_value'],
['datadirectory', \OC::$SERVERROOT.'/data', '/data/directory/'], ['datadirectory', \OC::$SERVERROOT.'/data', '/data/directory/'],
['logfile', '/data/directory/nextcloud.log', '/var/log/nextcloud.log'], ['logfile', '/data/directory/nextcloud.log', '/var/log/nextcloud.log'],
['log_rotate_size', 0, 5 * 1024 * 1024], ['log_rotate_size', 100 * 1024 * 1024, 5 * 1024 * 1024],
])); ]));
$this->consoleOutput->expects($this->at(0)) $this->consoleOutput->expects($this->at(0))