summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-22 01:17:31 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-22 01:17:31 -0700
commit9d976013daf971edf0c06460932e57de533c2ccf (patch)
treee055e60ad7acc8d934c82d1f245191ea29b31e25
parentefd71c80f05ce1aee1867c5fb9c4ebd217fe19d8 (diff)
parent5978ddbec6920f372dc0af0702459b85bfb57b71 (diff)
downloadnextcloud-server-9d976013daf971edf0c06460932e57de533c2ccf.tar.gz
nextcloud-server-9d976013daf971edf0c06460932e57de533c2ccf.zip
Merge pull request #5437 from owncloud/create-custom-logfile
Try to create custom log file before falling back to default.
-rw-r--r--lib/private/log/owncloud.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index 036c93cd8e1..15cace88f41 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -35,7 +35,17 @@ class OC_Log_Owncloud {
public static function init() {
$defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log';
self::$logFile = OC_Config::getValue("logfile", $defaultLogFile);
- if (!file_exists(self::$logFile)) {
+
+ /*
+ * Fall back to default log file if specified logfile does not exist
+ * and can not be created. Error suppression is required in order to
+ * not end up in the error handler which will try to log the error.
+ * A better solution (compared to error suppression) would be checking
+ * !is_writable(dirname(self::$logFile)) before touch(), but
+ * is_writable() on directories used to be pretty unreliable on Windows
+ * for at least some time.
+ */
+ if (!file_exists(self::$logFile) && !@touch(self::$logFile)) {
self::$logFile = $defaultLogFile;
}
}