Skip to content
Snippets Groups Projects
Commit e16be333 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #926 from owncloud/fix_issue_826

Fall back to default log file if logfile config file not found
parents dd5e39ca 39eebebd
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment