diff --git a/apps/bookmarks/lib/bookmarks.php b/apps/bookmarks/lib/bookmarks.php
old mode 100644
new mode 100755
index 81c1b03981aed56a3ad4a80a4ce6251fd36d1b52..b1ff1f411f2460795482ff084a9605385e369bbe
--- a/apps/bookmarks/lib/bookmarks.php
+++ b/apps/bookmarks/lib/bookmarks.php
@@ -34,7 +34,7 @@ class OC_Bookmarks_Bookmarks{
 	 * @return void
 	 */
 	public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly){
-		//OC_Log::write('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OC_Log::DEBUG);
+		//OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG);
 		$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );
 	
 		$params=array(OC_User::getUser());
diff --git a/apps/bookmarks/lib/search.php b/apps/bookmarks/lib/search.php
old mode 100644
new mode 100755
index d7e32558617198ce1b1abedc6fdbf76a967db45d..1e6a3ce910b9517f543ed8222119bcc4b8b2f322
--- a/apps/bookmarks/lib/search.php
+++ b/apps/bookmarks/lib/search.php
@@ -34,9 +34,9 @@ class OC_Search_Provider_Bookmarks extends OC_Search_Provider{
 			$searchquery = $query;
 		}
 		
-//		OC_Log::write('bookmarks', 'search ' .$query ,OC_Log::DEBUG);
+//		OCP\Util::writeLog('bookmarks', 'search ' .$query ,OCP\Util::DEBUG);
 		$bookmarks = OC_Bookmarks_Bookmarks::findBookmarks($offset, $sqlSortColumn, $searchquery, false);
-//		OC_Log::write('bookmarks', 'found ' .count($bookmarks) ,OC_Log::DEBUG);
+//		OCP\Util::writeLog('bookmarks', 'found ' .count($bookmarks) ,OCP\Util::DEBUG);
 		//$l = new OC_l10n('bookmarks'); //resulttype can't be localized, javascript relies on that type
 		foreach($bookmarks as $bookmark){
 			$results[]=new OC_Search_Result($bookmark['title'],'', $bookmark['url'],'Bookm.');
diff --git a/apps/calendar/ajax/categories/rescan.php b/apps/calendar/ajax/categories/rescan.php
old mode 100644
new mode 100755
index 9273986cad4816db90c5ea98793eba19ba822ba5..e1b276312a5f07e187e9983412f720906a1c87e7
--- a/apps/calendar/ajax/categories/rescan.php
+++ b/apps/calendar/ajax/categories/rescan.php
@@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('calendar','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('calendar','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
 }
 
 $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php
old mode 100644
new mode 100755
index 06d1a7e24fcdb84c8063071bee464c3351d0dfa9..b45d1a6ccbe844a393c3703280f2f0630c2894ae
--- a/apps/contacts/ajax/activation.php
+++ b/apps/contacts/ajax/activation.php
@@ -15,7 +15,7 @@ $bookid = $_POST['bookid'];
 $book = OC_Contacts_App::getAddressbook($bookid);// is owner access check
 
 if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
-	OC_Log::write('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
 	exit();
 }
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
old mode 100644
new mode 100755
index 152277181bb6b5ec119a408335be499e0d5c5bc0..d87cbabe819549f42eb197608de2bc67edcda4d6
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -24,11 +24,11 @@
  
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/addcontact.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/addcontact.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/addcontact.php: '.$msg, OCP\Util::DEBUG);
 }
 
 // Check if we are a user
@@ -56,7 +56,7 @@ $vcard->setString('N',$n);
 $id = OC_Contacts_VCard::add($aid,$vcard);
 if(!$id) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
-	OC_Log::write('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
old mode 100644
new mode 100755
index 9a5e59692d635ee0a160e81e5570c58ca281ffee..8623c6fdca77aa895753c063cef1978bd73abbb4
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -60,7 +60,7 @@ foreach($current as $item) {
 	$tmpvalue = (is_array($value)?implode(';', $value):$value);
 	if($tmpvalue == $item->value) {
 		OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Trying to add duplicate property: ').$name.': '.$tmpvalue)));
-		OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG);
+		OCP\Util::writeLog('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OCP\Util::DEBUG);
 		exit();
 	}
 }
@@ -118,7 +118,7 @@ $checksum = md5($vcard->children[$line]->serialize());
 
 if(!OC_Contacts_VCard::edit($id,$vcard)) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding contact property.'))));
-	OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OCP\Util::ERROR);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php
old mode 100644
new mode 100755
index 39a7758c8fbdbf276cee9a923b50b00e7419b19d..c6b753a73b5674cb46e16e7c79c1d61faab042b8
--- a/apps/contacts/ajax/categories/categoriesfor.php
+++ b/apps/contacts/ajax/categories/categoriesfor.php
@@ -17,7 +17,7 @@ if(is_null($id)) {
 }
 $vcard = OC_Contacts_App::getContactVCard( $id );
 foreach($vcard->children as $property){
-	//OC_Log::write('contacts','ajax/categories/checksumfor.php: '.$property->name, OC_Log::DEBUG);
+	//OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
 	if($property->name == 'CATEGORIES') {
 		$checksum = md5($property->serialize());
 		OC_JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
old mode 100644
new mode 100755
index 3cc2dea6638e41115c72e896416ea3bd7249a71a..f4e7ba76aa9767de53f880b016148b1a042db6cd
--- a/apps/contacts/ajax/categories/delete.php
+++ b/apps/contacts/ajax/categories/delete.php
@@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/categories/delete.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/categories/delete.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
 }
 
 $categories = isset($_POST['categories'])?$_POST['categories']:null;
diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php
old mode 100644
new mode 100755
index 09208c3f685fef4e2a987d719c7510f12510a42d..97fd1b22feaebd1ab0a638d4a685d004f887f002
--- a/apps/contacts/ajax/categories/rescan.php
+++ b/apps/contacts/ajax/categories/rescan.php
@@ -16,11 +16,11 @@ foreach ($_POST as $key=>$element) {
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/categories/rescan.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
 }
 
 $addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
old mode 100644
new mode 100755
index 87c2ecbcdadb4cce49335088a32568faa71eb6fd..aa6aca4562a1369dde22edd7f8e51d8572200bc7
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -24,7 +24,7 @@
  
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/contactdetails.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
old mode 100644
new mode 100755
index 5cdb9b49ef826e33136ab72c4b4f622084da8c27..6c9976f6fa3149ca90a57f5b082e5b486ab5762c
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -16,19 +16,19 @@ $userid = OC_User::getUser();
 $name = trim(strip_tags($_POST['name']));
 if(!$name) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
-	OC_Log::write('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
 	exit();
 }
 $bookid = OC_Contacts_Addressbook::add($userid, $name, null);
 if(!$bookid) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.'))));
-	OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR);
 	exit();
 }
 
 if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.'))));
-	OC_Log::write('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
 	//exit();
 }
 $addressbook = OC_Contacts_App::getAddressbook($bookid);
diff --git a/apps/contacts/ajax/cropphoto.php b/apps/contacts/ajax/cropphoto.php
old mode 100644
new mode 100755
index 96e66ffb69c5ea4d8f2699878a6a0029e2dd9250..09bdbbc439a5d4b1211590c09c65adc5300e8da9
--- a/apps/contacts/ajax/cropphoto.php
+++ b/apps/contacts/ajax/cropphoto.php
@@ -29,7 +29,7 @@ OC_JSON::checkAppEnabled('contacts');
 
 $tmp_path = $_GET['tmp_path'];
 $id = $_GET['id'];
-OC_Log::write('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG);
+OCP\Util::writeLog('contacts','ajax/cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
 $tmpl = new OC_TEMPLATE("contacts", "part.cropphoto");
 $tmpl->assign('tmp_path', $tmp_path);
 $tmpl->assign('id', $id);
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
old mode 100644
new mode 100755
index 171f5c347858309a9e4f9dd9afca33f1d6bffcb7..488f064836bebeb3bdccbe961fd8689961791aaf
--- a/apps/contacts/ajax/currentphoto.php
+++ b/apps/contacts/ajax/currentphoto.php
@@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/currentphoto.php: '.$msg, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/currentphoto.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::DEBUG);
 }
 
 if (!isset($_GET['id'])) {
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
old mode 100644
new mode 100755
index 98cdb85f0fc938cd56064174618d86dfd20696d9..84526e9b13b260855090c7fb20322cc383801346
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -21,7 +21,7 @@
  */
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
old mode 100644
new mode 100755
index 73786cb10cf07f858748ce50cc87e773ccaac77d..4c7538162189c9865f740f470a616172e8a20aae
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -41,7 +41,7 @@ unset($vcard->children[$line]);
 
 if(!OC_Contacts_VCard::edit($id,$vcard)) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.'))));
-	OC_Log::write('contacts','ajax/deleteproperty.php: Error deleting contact property', OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
old mode 100644
new mode 100755
index 9e4d6814620b37f66798df2f790e8d93cb63f8f2..0baa9403524111e29519ab98503fc10e9e1c43eb
--- a/apps/contacts/ajax/editname.php
+++ b/apps/contacts/ajax/editname.php
@@ -11,11 +11,11 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/editname.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
 }
 
 $tmpl = new OC_TEMPLATE("contacts", "part.edit_name_dialog");
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
old mode 100644
new mode 100755
index b2650a76f0e3ed698511ea8c875bd36d04a1441e..a2660130a258540c9ef713e25c0813fb1d669569
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -24,11 +24,11 @@
  
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/loadcard.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/loadcard.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/loadcard.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/loadcard.php: '.$msg, OCP\Util::DEBUG);
 }
 // foreach ($_POST as $key=>$element) {
 // 	debug('_POST: '.$key.'=>'.$element);
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
old mode 100644
new mode 100755
index c076d97a7c24dccde1258f2f03ee812d2d439663..8d40669a5b33e1a58e66a0a0dcf1d60926f684e2
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -26,12 +26,12 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 
 // foreach ($_POST as $key=>$element) {
-// 	OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);
+// 	OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
 // }
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/loadphoto.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php
old mode 100644
new mode 100755
index e46441c48210cdde90dd66ab13b2d48472d83fbe..8c6b95c556307df18a3a49ea57527028c8758ab8
--- a/apps/contacts/ajax/oc_photo.php
+++ b/apps/contacts/ajax/oc_photo.php
@@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/oc_photo.php: '.$msg, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/oc_photo.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::DEBUG);
 }
 
 if(!isset($_GET['id'])) {
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
old mode 100644
new mode 100755
index c1a0e2b0583b6691093420174bfc7a6c3afed1e6..36d582eca9c352dc6486e320fff71e59533ab307
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -23,14 +23,14 @@
  */
 // Init owncloud
  
-OC_Log::write('contacts','ajax/savecrop.php: Huzzah!!!', OC_Log::DEBUG);
+OCP\Util::writeLog('contacts','ajax/savecrop.php: Huzzah!!!', OCP\Util::DEBUG);
 
 // Check if we are a user
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 
 // foreach ($_POST as $key=>$element) {
-// 	OC_Log::write('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OC_Log::DEBUG);
+// 	OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$key.'=>'.$element, OCP\Util::DEBUG);
 // }
 
 // Firefox and Konqueror tries to download application/json for me.  --Arthur
@@ -38,7 +38,7 @@ OC_JSON::setContentTypeHeader('text/plain');
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/savecrop.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 
@@ -61,14 +61,14 @@ if($id == '') {
 	bailOut('Missing contact id.');
 }
 
-OC_Log::write('contacts','savecrop.php: files: '.$tmp_path.'  exists: '.file_exists($tmp_path), OC_Log::DEBUG);
+OCP\Util::writeLog('contacts','savecrop.php: files: '.$tmp_path.'  exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
 
 if(file_exists($tmp_path)) {
 	$image = new OC_Image();
 	if($image->loadFromFile($tmp_path)) {
 		$w = ($w != -1 ? $w : $image->width());
 		$h = ($h != -1 ? $h : $image->height());
-		OC_Log::write('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OC_Log::DEBUG);
+		OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
 		if($image->crop($x1, $y1, $w, $h)) {
 			if($image->resize(200)) {
 				$tmpfname = tempnam("/tmp", "occCropped"); // create a new file because of caching issues.
@@ -80,7 +80,7 @@ if(file_exists($tmp_path)) {
 						bailOut('Error getting contact object.');
 					}
 					if($card->__isset('PHOTO')) {
-						OC_Log::write('contacts','savecrop.php: PHOTO property exists.', OC_Log::DEBUG);
+						OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
 						$property = $card->__get('PHOTO');
 						if(!$property) {
 							unlink($tmpfname);
@@ -91,7 +91,7 @@ if(file_exists($tmp_path)) {
 						$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
 						$card->__set('PHOTO', $property);
 					} else {
-						OC_Log::write('contacts','savecrop.php: files: Adding PHOTO property.', OC_Log::DEBUG);
+						OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
 						$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
 					}
 					$now = new DateTime;
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
old mode 100644
new mode 100755
index e459ed733d8263bb819c9e92f0dfc3f77e6f86ad..b8b4a422cf2b6703086976751a0c60aed58c996a
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -29,11 +29,11 @@ OC_JSON::checkAppEnabled('contacts');
 
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
 }
 // foreach ($_POST as $key=>$element) {
 // 	debug('_POST: '.$key.'=>'.print_r($element, true));
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
old mode 100644
new mode 100755
index 06028db479a1f4c3a9745b352158fe673ffb8cd8..b016cf929390629f9393c0348cf0b9182b5d2cbf
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -18,19 +18,19 @@ OC_Contacts_App::getAddressbook($bookid); // is owner access check
 $name = trim(strip_tags($_POST['name']));
 if(!$name) {
 	OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'))));
-	OC_Log::write('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
 	exit();
 }
 
 if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) {
 	OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.'))));
-	OC_Log::write('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR);
 	//exit();
 }
 
 if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
 	OC_JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.'))));
-	OC_Log::write('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR);
 	//exit();
 }
 
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
old mode 100644
new mode 100755
index f44335a961e237256a239388fad838b3ca370ae3..e2bc6d7290b47198bf7db9a06224281a7e8f3647
--- a/apps/contacts/ajax/uploadimport.php
+++ b/apps/contacts/ajax/uploadimport.php
@@ -27,11 +27,11 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/uploadimport.php: '.$msg, OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/uploadimport.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::DEBUG);
 }
 
 $view = OC_App::getStorage('contacts');
@@ -51,7 +51,7 @@ if($fn) {
 
 // File input transfers are handled here
 if (!isset($_FILES['importfile'])) {
-	OC_Log::write('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
 	OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
 	exit();
 }
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
old mode 100644
new mode 100755
index 082776f7f2738fe376a64412d10c98ae7998cf16..1148c271dcdd7c5be7e9f2b2e245b7f7d46526af
--- a/apps/contacts/ajax/uploadphoto.php
+++ b/apps/contacts/ajax/uploadphoto.php
@@ -29,11 +29,11 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 function bailOut($msg) {
 	OC_JSON::error(array('data' => array('message' => $msg)));
-	OC_Log::write('contacts','ajax/uploadphoto.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
 	exit();
 }
 function debug($msg) {
-	OC_Log::write('contacts','ajax/uploadphoto.php: '.$msg, OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
 }
 
 // If it is a Drag'n'Drop transfer it's handled here.
@@ -41,7 +41,7 @@ $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : fals
 if ($fn) {
 	// AJAX call
 	if (!isset($_GET['id'])) {
-		OC_Log::write('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OC_Log::DEBUG);
+		OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG);
 		OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
 		exit();
 	}
@@ -70,12 +70,12 @@ if ($fn) {
 
 
 if (!isset($_POST['id'])) {
-	OC_Log::write('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No contact ID was submitted.', OCP\Util::DEBUG);
 	OC_JSON::error(array('data' => array( 'message' => 'No contact ID was submitted.' )));
 	exit();
 }
 if (!isset($_FILES['imagefile'])) {
-	OC_Log::write('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
 	OC_JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
 	exit();
 }
diff --git a/apps/contacts/dynphoto.php b/apps/contacts/dynphoto.php
old mode 100644
new mode 100755
index c1646e483deb7fb624753ec7403eb7d9ef747ce6..ea6cef227e1d16a79657abeabe29dd329b5c2ede
--- a/apps/contacts/dynphoto.php
+++ b/apps/contacts/dynphoto.php
@@ -26,7 +26,7 @@ $tmp_path = $_GET['tmp_path'];
 $maxsize = isset($_GET['maxsize']) ? $_GET['maxsize'] : -1;
 header("Cache-Control: no-cache, no-store, must-revalidate");
 
-OC_Log::write('contacts','dynphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG);
+OCP\Util::writeLog('contacts','dynphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
 
 $image = new OC_Image($tmp_path);
 if($maxsize != -1) {
diff --git a/apps/contacts/import.php b/apps/contacts/import.php
old mode 100644
new mode 100755
index 8e0a427399b008c56730df781bf2a6686e5a9530..8fb1c055e0f3e66546fdd7b4f9b935887ad3a10f
--- a/apps/contacts/import.php
+++ b/apps/contacts/import.php
@@ -116,7 +116,7 @@ foreach($importready as $import){
 	$card = OC_VObject::parse($import);
 	if (!$card) {
 		$failed += 1;
-		OC_Log::write('contacts','Import: skipping card. Error parsing VCard: '.$import, OC_Log::ERROR);
+		OCP\Util::writeLog('contacts','Import: skipping card. Error parsing VCard: '.$import, OCP\Util::ERROR);
 		continue; // Ditch cards that can't be parsed by Sabre.
 	}
 	$imported += 1;
@@ -134,7 +134,7 @@ if(is_writable('import_tmp/')){
 }
 if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
 	if(!$view->unlink('/' . $_POST['file'])) {
-		OC_Log::write('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OC_Log::ERROR);
+		OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR);
 	}
 }
 OC_JSON::success(array('data' => array('imported'=>$imported, 'failed'=>$failed)));
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
old mode 100644
new mode 100755
index 9061fa1914042dff24874f31f80f50227d6a6861..bf1cb9323dbb0e0635e4e0b6857b3f768d4cd63e
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -195,9 +195,9 @@ class OC_Contacts_Addressbook{
 			$stmt = OC_DB::prepare( $prep );
 			$result = $stmt->execute($active);
 		} catch(Exception $e) {
-			OC_Log::write('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-			OC_Log::write('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OC_Log::DEBUG);
-			OC_Log::write('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OC_Log::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_Addressbook:active, ids: '.join(',', $active),OCP\Util::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::active, SQL:'.$prep,OCP\Util::DEBUG);
 		}
 
 		while( $row = $result->fetchRow()){
@@ -246,7 +246,7 @@ class OC_Contacts_Addressbook{
 	 * @return boolean
 	 */
 	public static function isActive($id){
-		//OC_Log::write('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OC_Log::DEBUG);
+		//OCP\Util::writeLog('contacts','OC_Contacts_Addressbook::isActive('.$id.'):'.in_array($id, self::activeIds()), OCP\Util::DEBUG);
 		return in_array($id, self::activeIds());
 	}
 
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
old mode 100644
new mode 100755
index 128b9cd660d5530d3d1ae6c0dc1fd6934fb2b2e7..26ea6d06092599e79caf3503c89aa2e1d6410ce9
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -19,11 +19,11 @@ class OC_Contacts_App {
 		$addressbook = OC_Contacts_Addressbook::find( $id );
 		if( $addressbook === false || $addressbook['userid'] != OC_User::getUser()) {
 			if ($addressbook === false) {
-				OC_Log::write('contacts', 'Addressbook not found: '. $id, OC_Log::ERROR);
+				OCP\Util::writeLog('contacts', 'Addressbook not found: '. $id, OCP\Util::ERROR);
 				OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Addressbook not found.'))));
 			}
 			else {
-				OC_Log::write('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OC_Log::ERROR);
+				OCP\Util::writeLog('contacts', 'Addressbook('.$id.') is not from '.OC_User::getUser(), OCP\Util::ERROR);
 				OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('This is not your addressbook.'))));
 			}
 			exit();
@@ -34,7 +34,7 @@ class OC_Contacts_App {
 	public static function getContactObject($id) {
 		$card = OC_Contacts_VCard::find( $id );
 		if( $card === false ) {
-			OC_Log::write('contacts', 'Contact could not be found: '.$id, OC_Log::ERROR);
+			OCP\Util::writeLog('contacts', 'Contact could not be found: '.$id, OCP\Util::ERROR);
 			OC_JSON::error(array('data' => array( 'message' => self::$l10n->t('Contact could not be found.').' '.$id)));
 			exit();
 		}
@@ -55,11 +55,11 @@ class OC_Contacts_App {
 		if(!is_null($vcard) && !$vcard->__isset('N')) {
 			$appinfo = OC_App::getAppInfo('contacts');
 			if($appinfo['version'] >= 5) {
-				OC_Log::write('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OCP\Util::DEBUG);
 			}
-			OC_Log::write('contacts','getContactVCard, Missing N field', OC_Log::DEBUG);
+			OCP\Util::writeLog('contacts','getContactVCard, Missing N field', OCP\Util::DEBUG);
 			if($vcard->__isset('FN')) {
-				OC_Log::write('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','getContactVCard, found FN field: '.$vcard->__get('FN'), OCP\Util::DEBUG);
 				$n = implode(';', array_reverse(array_slice(explode(' ', $vcard->__get('FN')), 0, 2))).';;;';
 				$vcard->setString('N', $n);
 				OC_Contacts_VCard::edit( $id, $vcard);
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
old mode 100644
new mode 100755
index d8cce36b80bc746462ef8578ec930724bd9bf2ac..45ce1ac3a2c2a91cafb028fafd5df8e7fca700c0
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -56,17 +56,17 @@ class OC_Contacts_VCard{
 				$stmt = OC_DB::prepare( $prep );
 				$result = $stmt->execute($id);
 			} catch(Exception $e) {
-				OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-				OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OC_Log::DEBUG);
-				OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '.join(',', $id),OCP\Util::DEBUG);
+				OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG);
 			}
 		} elseif($id) {
 			try {
 				$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? ORDER BY fullname' );
 				$result = $stmt->execute(array($id));
 			} catch(Exception $e) {
-				OC_Log::write('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-				OC_Log::write('contacts','OC_Contacts_VCard:all, ids: '. $id,OC_Log::DEBUG);
+				OC\Util::writeLog('contacts','OC_Contacts_VCard:all:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+				OC\Util::writeLog('contacts','OC_Contacts_VCard:all, ids: '. $id,OCP\Util::DEBUG);
 			}
 		}
 		$cards = array();
@@ -181,7 +181,7 @@ class OC_Contacts_VCard{
 		// Add version if needed
 		if($version && $version < '3.0') {
 			$upgrade = true;
-			OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OC_Log::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Updating from version: '.$version,OCP\Util::DEBUG);
 		}
 		foreach($vcard->children as &$property){
 			// Decode string properties and remove obsolete properties.
@@ -190,9 +190,9 @@ class OC_Contacts_VCard{
 			}
 			// Fix format of type parameters.
 			if($upgrade && in_array($property->name, $typeprops)) {
-				OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. before: '.$property->serialize(),OCP\Util::DEBUG);
 				self::formatPropertyTypes($property);
-				OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. after: '.$property->serialize(),OCP\Util::DEBUG);
 			}
 			if($property->name == 'FN'){
 				$fn = $property->value;
@@ -222,7 +222,7 @@ class OC_Contacts_VCard{
 				$fn = 'Unknown Name';
 			}
 			$vcard->setString('FN', $fn);
-			OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OC_Log::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'FN\' field: '.$fn,OCP\Util::DEBUG);
 		}
 		if(!$n || $n = ';;;;'){ // Fix missing 'N' field. Ugly hack ahead ;-)
 			$slice = array_reverse(array_slice(explode(' ', $fn), 0, 2)); // Take 2 first name parts of 'FN' and reverse.
@@ -231,12 +231,12 @@ class OC_Contacts_VCard{
 			}
 			$n = implode(';', $slice).';;;';
 			$vcard->setString('N', $n);
-			OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
+			OC\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'N\' field: '.$n,OCP\Util::DEBUG);
 		}
 		if(!$uid) {
 			$vcard->setUID();
 			$uid = $vcard->getAsString('UID');
-			OC_Log::write('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OC_Log::DEBUG);
+			OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateValuesFromAdd. Added missing \'UID\' field: '.$uid,OCP\Util::DEBUG);
 		}
 		if(self::trueUID($aid, $uid)) {
 			$vcard->setString('UID', $uid);
@@ -263,7 +263,7 @@ class OC_Contacts_VCard{
 	 */
 	public static function add($aid, OC_VObject $card, $uri=null){
 		if(is_null($card)){
-			OC_Log::write('contacts','OC_Contacts_VCard::add. No vCard supplied', OC_Log::ERROR);
+			OCP\Util::writeLog('contacts','OC_Contacts_VCard::add. No vCard supplied', OCP\Util::ERROR);
 			return null;
 		};
 
@@ -317,10 +317,10 @@ class OC_Contacts_VCard{
 				$data = $vcard->serialize();
 				try {
 					$result = $stmt->execute(array($data,time(),$object[0]));
-					//OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OC_Log::DEBUG);
+					//OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0].': '.$object[1],OCP\Util::DEBUG);
 				} catch(Exception $e) {
-					OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-					OC_Log::write('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0],OC_Log::DEBUG);
+					OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+					OCP\Util::writeLog('contacts','OC_Contacts_VCard::updateDataByID, id: '.$object[0],OCP\Util::DEBUG);
 				}
 			}
 		}
@@ -526,9 +526,9 @@ class OC_Contacts_VCard{
 				$vals = array_merge((array)$aid, $id);
 				$result = $stmt->execute($vals);
 			} catch(Exception $e) {
-				OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-				OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OC_Log::DEBUG);
-				OC_Log::write('contacts','SQL:'.$prep,OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, ids: '.join(',', $vals),OCP\Util::DEBUG);
+				OCP\Util::writeLog('contacts','SQL:'.$prep,OCP\Util::DEBUG);
 				return false;
 			}
 		} else {
@@ -536,8 +536,8 @@ class OC_Contacts_VCard{
 				$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?' );
 				$result = $stmt->execute(array($aid, $id));
 			} catch(Exception $e) {
-				OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OC_Log::DEBUG);
-				OC_Log::write('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OC_Log::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook:, exception: '.$e->getMessage(),OCP\Util::DEBUG);
+				OCP\Util::writeLog('contacts','OC_Contacts_VCard::moveToAddressBook, id: '.$id,OCP\Util::DEBUG);
 				return false;
 			}
 		}
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
old mode 100644
new mode 100755
index c19ccccbc7fafe193020bd60ab3b7d2abaab0b17..f9e62455c13040fafcec0019603bea5ee806b667
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -33,7 +33,7 @@ if(!$image) {
 }
 // invalid vcard
 if( is_null($contact)) {
-	OC_Log::write('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','photo.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
 } else {
 	OC_Response::enableCaching($caching);
 	OC_Contacts_App::setLastModifiedHeader($contact);
diff --git a/apps/contacts/templates/part.cropphoto.php b/apps/contacts/templates/part.cropphoto.php
old mode 100644
new mode 100755
index 5faa4aa6ac6a2352f14de0e15a6b6f86adc2612a..2284d49aca98838e9a9409748b5d84b16ef3cdba
--- a/apps/contacts/templates/part.cropphoto.php
+++ b/apps/contacts/templates/part.cropphoto.php
@@ -1,7 +1,7 @@
 <?php 
 $id = $_['id'];
 $tmp_path = $_['tmp_path'];
-OC_Log::write('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OC_Log::DEBUG);
+OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
 ?>
 <script language="Javascript">
 	jQuery(function($) {
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
old mode 100644
new mode 100755
index 13f16954cafeec67e3279d056efc4d249cd6907b..1f9fbd7135e4c2361ceaf11e463df493d98445c4
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -33,7 +33,7 @@ function getStandardImage(){
 }
 
 if(!function_exists('imagecreatefromjpeg')) {
-	OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG);
+	OCP\Util::writeLog('contacts','thumbnail.php. GD module not installed',OCP\Util::DEBUG);
 	getStandardImage();
 	exit();
 }
@@ -45,7 +45,7 @@ $contact = OC_Contacts_App::getContactVCard($id);
 
 // invalid vcard
 if(is_null($contact)){
-	OC_Log::write('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OC_Log::ERROR);
+	OCP\Util::writeLog('contacts','thumbnail.php. The VCard for ID '.$id.' is not RFC compatible',OCP\Util::ERROR);
 	getStandardImage();
 	exit();
 }
@@ -67,16 +67,16 @@ if($photo) {
 					// done
 					exit();
 				} else {
-					OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR);
+					OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OCP\Util::ERROR);
 				}
 			} else {
-				OC_Log::write('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OC_Log::ERROR);
+				OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t resize thumbnail for ID '.$id,OCP\Util::ERROR);
 			}
 		}else{
-			OC_Log::write('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OC_Log::ERROR);
+			OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t crop thumbnail for ID '.$id,OCP\Util::ERROR);
 		}
 	} else {
-		OC_Log::write('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OC_Log::ERROR);
+		OCP\Util::writeLog('contacts','thumbnail.php. Couldn\'t load image string for ID '.$id,OCP\Util::ERROR);
 	}
 }
 getStandardImage();
diff --git a/apps/files_archive/lib/zip.php b/apps/files_archive/lib/zip.php
old mode 100644
new mode 100755
index 5a5bc766875ddde02b3d02abac2f2fd825dc274b..dd94859f08906f21ff1d179eabdaf72d6918c64b
--- a/apps/files_archive/lib/zip.php
+++ b/apps/files_archive/lib/zip.php
@@ -19,7 +19,7 @@ class OC_Archive_ZIP extends OC_Archive{
 		$this->zip=new ZipArchive();
 		if($this->zip->open($source,ZipArchive::CREATE)){
 		}else{
-			OC_LOG::write('files_archive','Error while opening archive '.$source,OC_Log::WARN);
+			OCP\Util::writeLog('files_archive','Error while opening archive '.$source,OCP\Util::WARN);
 		}
 	}
 	/**
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php
old mode 100644
new mode 100755
index 07a2e523a4292f080ef895cc2ca3e169595f074f..1a7c595cb838a6eabb340a98d039a302a6fbef64
--- a/apps/files_encryption/lib/cryptstream.php
+++ b/apps/files_encryption/lib/cryptstream.php
@@ -42,12 +42,12 @@ class OC_CryptStream{
 			$this->path=self::$sourceStreams[basename($path)]['path'];
 		}else{
 			$this->path=$path;
-			OC_Log::write('files_encryption','open encrypted '.$path. ' in '.$mode,OC_Log::DEBUG);
+			OCP\Util::writeLog('files_encryption','open encrypted '.$path. ' in '.$mode,OCP\Util::DEBUG);
 			OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file
 			$this->source=OC_FileSystem::fopen($path,$mode);
 			OC_FileProxy::$enabled=true;
 			if(!is_resource($this->source)){
-				OC_Log::write('files_encryption','failed to open '.$path,OC_Log::ERROR);
+				OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR);
 			}
 		}
 		if(is_resource($this->source)){
@@ -68,7 +68,7 @@ class OC_CryptStream{
 		//$count will always be 8192 https://bugs.php.net/bug.php?id=21641
 		//This makes this function a lot simpler but will breake everything the moment it's fixed
 		if($count!=8192){
-			OC_Log::write('files_encryption','php bug 21641 no longer holds, decryption will not work',OC_Log::FATAL);
+			OCP\Util::writeLog('files_encryption','php bug 21641 no longer holds, decryption will not work',OCP\Util::FATAL);
 			die();
 		}
 		$data=fread($this->source,8192);
@@ -135,4 +135,4 @@ class OC_CryptStream{
 		}
 		return fclose($this->source);
 	}
-}
\ No newline at end of file
+}
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
old mode 100644
new mode 100755
index d65bcba8bfa1dc80056921b14d46a9ed43a073dd..11a6a84e667f3015718baa3ade47de63b6ff7bb6
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -90,7 +90,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
 		}elseif(self::shouldEncrypt($path) and $meta['mode']!='r' and $meta['mode']!='rb'){
 			if(OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path)>0){
 				//first encrypt the target file so we don't end up with a half encrypted file
-				OC_Log::write('files_encryption','Decrypting '.$path.' before writing',OC_Log::DEBUG);
+				OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG);
 				$tmp=fopen('php://temp');
 				OC_Helper::streamCopy($result,$tmp);
 				fclose($result);
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
old mode 100644
new mode 100755
index 50c6d4c9d25b247f6a3c4b3b37e6816ba61a0cb2..c704f653c11130290e3f4f6346d74c0948a565be
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -15,7 +15,7 @@ foreach ($sources as $source) {
 		$source = $userDirectory.$source;
 	// If the file doesn't exist, it may be shared with the current user
 	} else if (!$source = OC_Share::getSource($userDirectory.$source)) {
-		OC_Log::write('files_sharing',"Shared file doesn't exists :".$source,OC_Log::ERROR);
+		OCP\Util::writeLog('files_sharing',"Shared file doesn't exists :".$source,OCP\Util::ERROR);
 		echo "false";
 	}
 	try {
@@ -24,7 +24,7 @@ foreach ($sources as $source) {
 			echo $shared->getToken();
 		}
 	} catch (Exception $exception) {
-		OC_Log::write('files_sharing',"Unexpected Error : ".$exception->getMessage(),OC_Log::ERROR);
+		OC\Util::writeLog('files_sharing',"Unexpected Error : ".$exception->getMessage(),OCP\Util::ERROR);
 		echo "false";
 	}
 }
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
old mode 100644
new mode 100755
index 62ac05a59529c1da8a27345ab7455cf9fc398dad..c5127c59cbdab727a8592a1613491a6dfd496e97
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -310,7 +310,7 @@ class OC_Share {
 					return $result[0]['permissions'];
 				}
 			} else {
-				OC_Log::write('files_sharing',"Not existing parent folder : ".$target,OC_Log::ERROR);
+				OCP\Util::writeLog('files_sharing',"Not existing parent folder : ".$target,OCP\Util::ERROR);
 				return false;
 			}
 		}
diff --git a/apps/files_texteditor/ajax/savefile.php b/apps/files_texteditor/ajax/savefile.php
old mode 100644
new mode 100755
index 9f67cc4b4e6f325381448ecb6ece468869801dcc..7c7fb90e7c6d21555fa3defc9fca17b5088a0b6e
--- a/apps/files_texteditor/ajax/savefile.php
+++ b/apps/files_texteditor/ajax/savefile.php
@@ -40,7 +40,7 @@ if($path != '' && $mtime != '')
 	{
 		// Then the file has changed since opening
 		OC_JSON::error();
-		OC_Log::write('files_texteditor',"File: ".$path." modified since opening.",OC_Log::ERROR);	
+		OCP\Util::writeLog('files_texteditor',"File: ".$path." modified since opening.",OCP\Util::ERROR);	
 	}
 	else
 	{
@@ -59,10 +59,10 @@ if($path != '' && $mtime != '')
 		{
 			// Not writeable!
 			OC_JSON::error(array('data' => array( 'message' => 'Insufficient permissions')));	
-			OC_Log::write('files_texteditor',"User does not have permission to write to file: ".$path,OC_Log::ERROR);
+			OCP\Util::writeLog('files_texteditor',"User does not have permission to write to file: ".$path,OCP\Util::ERROR);
 		}
 	}
 } else {
 	OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied')));
-	OC_Log::write('files_texteditor',"Invalid path supplied:".$path,OC_Log::ERROR);	
+	OCP\Util::writeLog('files_texteditor',"Invalid path supplied:".$path,OCP\Util::ERROR);	
 }
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php
old mode 100644
new mode 100755
index 737c38c0593464da303aa65d06887e1d7df9182d..9257bbce6288fc06704ef7bcca84e409782752f1
--- a/apps/gallery/lib/hooks_handlers.php
+++ b/apps/gallery/lib/hooks_handlers.php
@@ -52,7 +52,7 @@ class OC_Gallery_Hooks_Handlers {
     if ($new_album_name == '')
       $new_album_name = 'main';
 
-    OCP\Util::writeLog(self::$APP_TAG, 'Creating new album '.$new_album_name, OC_Log::DEBUG);
+    OCP\Util::writeLog(self::$APP_TAG, 'Creating new album '.$new_album_name, OCP\Util::DEBUG);
     OC_Gallery_Album::create(OC_User::getUser(), $new_album_name, $path);
 
     return OC_Gallery_Album::find(OC_User::getUser(), null, $path);
@@ -110,7 +110,7 @@ class OC_Gallery_Hooks_Handlers {
       if ($olddir == '') $olddir = '/';
       if ($newdir == '') $newdir = '/';
       if (!self::isPhoto($newpath)) return;
-      OCP\Util::writeLog(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OC_Log::DEBUG);
+      OCP\Util::writeLog(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OCP\Util::DEBUG);
       $album;
       $newAlbumId;
       $oldAlbumId;
diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php
old mode 100644
new mode 100755
index 5d652c1b39de60c0df7d1df256d49e6be246958f..dc2a8a9beb4a1eef53e34feb747c0f9163529be7
--- a/apps/media/lib_scanner.php
+++ b/apps/media/lib_scanner.php
@@ -72,23 +72,23 @@ class OC_MEDIA_SCANNER{
 		$data=@self::$getID3->analyze($file);
 		getid3_lib::CopyTagsToComments($data);
 		if(!isset($data['comments'])){
-			OCP\Util::writeLog('media',"error reading id3 tags in '$file'",OC_Log::WARN);
+			OCP\Util::writeLog('media',"error reading id3 tags in '$file'",OCP\Util::WARN);
 			return;
 		}
 		if(!isset($data['comments']['artist'])){
-			OCP\Util::writeLog('media',"error reading artist tag in '$file'",OC_Log::WARN);
+			OCP\Util::writeLog('media',"error reading artist tag in '$file'",OCP\Util::WARN);
 			$artist='unknown';
 		}else{
 			$artist=stripslashes($data['comments']['artist'][0]);
 		}
 		if(!isset($data['comments']['album'])){
-			OCP\Util::writeLog('media',"error reading album tag in '$file'",OC_Log::WARN);
+			OCP\Util::writeLog('media',"error reading album tag in '$file'",OCP\Util::WARN);
 			$album='unknown';
 		}else{
 			$album=stripslashes($data['comments']['album'][0]);
 		}
 		if(!isset($data['comments']['title'])){
-			OCP\Util::writeLog('media',"error reading title tag in '$file'",OC_Log::WARN);
+			OCP\Util::writeLog('media',"error reading title tag in '$file'",OCP\Util::WARN);
 			$title='unknown';
 		}else{
 			$title=stripslashes($data['comments']['title'][0]);
diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php
old mode 100644
new mode 100755
index 1ef48d551b5675f7ee7c3d6e26724e8b2e56f89c..bf277f3491cbd6fcc3547e63957cc89a413a370e
--- a/apps/media/server/xml.server.php
+++ b/apps/media/server/xml.server.php
@@ -37,7 +37,7 @@ foreach($arguments as &$argument){
 }
 @ob_clean();
 if(isset($arguments['action'])){
-	OCP\Util::writeLog('media','ampache '.$arguments['action'].' request', OC_Log::DEBUG);
+	OCP\Util::writeLog('media','ampache '.$arguments['action'].' request', OCP\Util::DEBUG);
 	switch($arguments['action']){
 		case 'songs':
 			OC_MEDIA_AMPACHE::songs($arguments);
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
old mode 100644
new mode 100755
index 55ef44c5d9a91aad7bffc05f79fc6eb46445175a..327f6958ebfceb33fe6066af9bdebdc93c55c633
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -529,7 +529,7 @@ class OC_LDAP {
 			self::init();
 		}
 		if(is_null(self::$ldapConnectionRes)) {
-			OCP\Util::writeLog('ldap', 'Connection could not be established', OC_Log::INFO);
+			OCP\Util::writeLog('ldap', 'Connection could not be established', OCP\Util::INFO);
 		}
 		return self::$ldapConnectionRes;
 	}
diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php
old mode 100644
new mode 100755
index 643d58867efd9d3e07ae86e6d2b5593a9dffb0cf..e94bda5baec4d41c974728107d03407991f4544b
--- a/apps/user_migrate/admin.php
+++ b/apps/user_migrate/admin.php
@@ -37,7 +37,7 @@ if (isset($_POST['user_import'])) {
 	$to = get_temp_dir().'/'.$importname.'.zip';
 	if( !move_uploaded_file( $from, $to ) ){
 		$error = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.');
-		OCP\Util::writeLog( 'user_migrate', "Failed to copy the uploaded file", OC_Log::ERROR );
+		OCP\Util::writeLog( 'user_migrate', "Failed to copy the uploaded file", OCP\Util::ERROR );
 		$tmpl = new OC_Template('user_migrate', 'admin');
 		$tmpl->assign('error',$error);
     	return $tmpl->fetchPage();
diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php
old mode 100644
new mode 100755
index 730039570a07972cbf647ba854dd0263494bf503..867a0a3ed33380110e63bfce0d19e27e905390c8
--- a/apps/user_openid/appinfo/app.php
+++ b/apps/user_openid/appinfo/app.php
@@ -26,14 +26,14 @@ OC_User::useBackend('openid');
 
 //check for results from openid requests
 if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
-	OCP\Util::writeLog('user_openid','openid retured',OC_Log::DEBUG);
+	OCP\Util::writeLog('user_openid','openid retured',OCP\Util::DEBUG);
 	$openid = new SimpleOpenID;
 	$openid->SetIdentity($_GET['openid_identity']);
 	$openid_validation_result = $openid->ValidateWithServer();
 	if ($openid_validation_result == true){         // OK HERE KEY IS VALID
-		OCP\Util::writeLog('user_openid','auth sucessfull',OC_Log::DEBUG);
+		OCP\Util::writeLog('user_openid','auth sucessfull',OCP\Util::DEBUG);
 		$identity=$openid->GetIdentity();
-		OCP\Util::writeLog('user_openid','auth as '.$identity,OC_Log::DEBUG);
+		OCP\Util::writeLog('user_openid','auth as '.$identity,OCP\Util::DEBUG);
 		$user=OC_USER_OPENID::findUserForIdentity($identity);
 		if($user){
 			$_SESSION['user_id']=$user;
@@ -41,13 +41,13 @@ if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){
 		}
 	}else if($openid->IsError() == true){            // ON THE WAY, WE GOT SOME ERROR
 		$error = $openid->GetError();
-		OCP\Util::writeLog('user_openid','ERROR CODE: '. $error['code'],OC_Log::ERROR);
-		OCP\Util::writeLog('user_openid','ERROR DESCRIPTION: '. $error['description'],OC_Log::ERROR);
+		OCP\Util::writeLog('user_openid','ERROR CODE: '. $error['code'],OCP\Util::ERROR);
+		OCP\Util::writeLog('user_openid','ERROR DESCRIPTION: '. $error['description'],OCP\Util::ERROR);
 	}else{                                            // Signature Verification Failed
-		OCP\Util::writeLog('user_openid','INVALID AUTHORIZATION',OC_Log::ERROR);
+		OCP\Util::writeLog('user_openid','INVALID AUTHORIZATION',OCP\Util::ERROR);
 	}
 }else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request
-	OCP\Util::writeLog('user_openid','USER CANCELED REQUEST',OC_Log::DEBUG);
+	OCP\Util::writeLog('user_openid','USER CANCELED REQUEST',OCP\Util::DEBUG);
 	return false;
 }
 
diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php
old mode 100644
new mode 100755
index edaa825baf7cfb700eab2ad2345f6f7fdca16881..59220aedc569fa7b29c5364b72c6fe6b85caefb6
--- a/apps/user_openid/user.php
+++ b/apps/user_openid/user.php
@@ -40,7 +40,7 @@ require_once '../../lib/base.php';
 OC_Util::checkAppEnabled('user_openid');
 
 if(!OC_User::userExists($USERNAME)){
-	OCP\Util::writeLog('user_openid',$USERNAME.' doesn\'t exist',OC_Log::WARN);
+	OCP\Util::writeLog('user_openid',$USERNAME.' doesn\'t exist',OCP\Util::WARN);
 	$USERNAME='';
 }
 $IDENTITY=OC_Helper::linkToAbsolute( "user_openid", "user.php" ).'/'.$USERNAME;
diff --git a/lib/public/util.php b/lib/public/util.php
index 8c52ff28b8336302000b893ddb340dd4bfa12a98..3e647fc6605a0aabb92ba0463296eea47ac66814 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -32,6 +32,13 @@ namespace OCP;
 
 class Util {
 
+	// consts for Logging
+	const DEBUG=0;
+	const INFO=1;
+	const WARN=2;
+	const ERROR=3;
+	const FATAL=4;
+
 	/**
 	 * send an email 
 	 *
@@ -57,7 +64,7 @@ class Util {
 	 * @param string $message
 	 * @param int level
          */
-        public static function writelog($app, $message, $level) {
+        public static function writeLog($app, $message, $level) {
 
                 // call the internal log class
                 \OC_LOG::write($app, $message, $level);