diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2012-12-17 02:05:06 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2012-12-17 02:05:06 -0800 |
commit | e16be33384e49276ef9b483b6c8f667ad688e372 (patch) | |
tree | 3b0667a6e641e23f702b9a2741c7976cb8068de3 | |
parent | dd5e39ca71d80c97e1b62427642ba1a08f75624d (diff) | |
parent | 39eebebd9994f38641070da4a79bc5110472ba12 (diff) | |
download | nextcloud-server-e16be33384e49276ef9b483b6c8f667ad688e372.tar.gz nextcloud-server-e16be33384e49276ef9b483b6c8f667ad688e372.zip |
Merge pull request #926 from owncloud/fix_issue_826
Fall back to default log file if logfile config file not found
-rw-r--r-- | lib/log/owncloud.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index ec43208d833..e53dd5fefcd 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -33,8 +33,11 @@ class OC_Log_Owncloud { * Init class data */ public static function init() { - $datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' ); - self::$logFile=OC_Config::getValue( "logfile", $datadir.'/owncloud.log' ); + $defaultLogFile = OC_Config::getValue("datadirectory", OC::$SERVERROOT.'/data').'/owncloud.log'; + self::$logFile = OC_Config::getValue("logfile", $defaultLogFile); + if (!file_exists(self::$logFile)) { + self::$logFile = $defaultLogFile; + } } /** @@ -47,9 +50,11 @@ class OC_Log_Owncloud { $minLevel=min(OC_Config::getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR); if($level>=$minLevel) { $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=>time()); - $fh=fopen(self::$logFile, 'a'); - fwrite($fh, json_encode($entry)."\n"); - fclose($fh); + $handle = @fopen(self::$logFile, 'a'); + if ($handle) { + fwrite($handle, json_encode($entry)."\n"); + fclose($handle); + } } } |