From d3ac73c0c9419750c65d3ccb8f0b0c25edacf34f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Fri, 3 Jul 2015 14:06:40 +0200
Subject: [PATCH] Remove OC_Log

---
 apps/files_sharing/ajax/publicpreview.php |  2 +-
 apps/files_trashbin/lib/trashbin.php      |  8 +--
 core/ajax/preview.php                     |  4 +-
 core/ajax/update.php                      |  3 +-
 core/setup/controller.php                 |  2 +-
 cron.php                                  |  2 +-
 lib/autoloader.php                        |  2 +-
 lib/base.php                              |  9 +--
 lib/private/app.php                       | 10 ++--
 lib/private/cache/file.php                |  2 +-
 lib/private/connector/sabre/file.php      |  6 +-
 lib/private/db.php                        |  4 +-
 lib/private/db/connection.php             |  2 +-
 lib/private/db/statementwrapper.php       |  2 +-
 lib/private/files.php                     |  4 +-
 lib/private/files/cache/cache.php         |  2 +-
 lib/private/files/cache/scanner.php       |  2 +-
 lib/private/files/mount/mountpoint.php    |  4 +-
 lib/private/files/storage/local.php       |  6 +-
 lib/private/files/view.php                |  2 +-
 lib/private/hook.php                      |  4 +-
 lib/private/installer.php                 |  2 +-
 lib/private/legacy/log.php                | 69 ----------------------
 lib/private/log.php                       | 22 +++----
 lib/private/log/owncloud.php              |  6 +-
 lib/private/log/rotate.php                |  2 +-
 lib/private/log/syslog.php                | 10 ++--
 lib/private/naturalsort.php               |  2 +-
 lib/private/ocsclient.php                 |  2 +-
 lib/private/preview.php                   |  2 +-
 lib/private/preview/bitmap.php            |  2 +-
 lib/private/preview/office.php            |  2 +-
 lib/private/preview/svg.php               |  2 +-
 lib/private/setup/mssql.php               | 20 +++----
 lib/private/setup/mysql.php               |  2 +-
 lib/private/setup/oci.php                 | 22 +++----
 lib/private/setup/postgresql.php          | 10 ++--
 lib/private/share/share.php               | 70 +++++++++++------------
 lib/private/user.php                      |  8 +--
 lib/private/user/database.php             |  4 +-
 lib/private/util.php                      |  2 +-
 lib/public/util.php                       |  2 +-
 settings/ajax/enableapp.php               |  2 +-
 tests/bootstrap.php                       |  2 +-
 tests/lib/logger.php                      |  2 +-
 45 files changed, 142 insertions(+), 209 deletions(-)
 delete mode 100644 lib/private/legacy/log.php

diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index 99a5bdaa85..6ddd4786c2 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -66,7 +66,7 @@ $path = $view->getPath($pathId);
 
 if($path === null) {
 	\OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
-	\OC_Log::write('core-preview', 'Could not resolve file for shared item', OC_Log::WARN);
+	\OCP\Util::writeLog('core-preview', 'Could not resolve file for shared item', \OCP\Util::WARN);
 	exit;
 }
 
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 2d4ea7adc1..8b666c56c6 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -160,7 +160,7 @@ class Trashbin {
 			$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
 			$result = $query->execute(array($ownerFilename, $timestamp, $ownerLocation, $owner));
 			if (!$result) {
-				\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated for the files owner', \OC_log::ERROR);
+				\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated for the files owner', \OCP\Util::ERROR);
 			}
 		}
 	}
@@ -216,7 +216,7 @@ class Trashbin {
 			if ($trashStorage->file_exists($trashInternalPath)) {
 				$trashStorage->unlink($trashInternalPath);
 			}
-			\OCP\Util::writeLog('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR);
+			\OCP\Util::writeLog('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OCP\Util::ERROR);
 		}
 
 		if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
@@ -231,7 +231,7 @@ class Trashbin {
 			$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");
 			$result = $query->execute(array($filename, $timestamp, $location, $user));
 			if (!$result) {
-				\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR);
+				\OCP\Util::writeLog('files_trashbin', 'trash bin database couldn\'t be updated', \OCP\Util::ERROR);
 			}
 			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', array('filePath' => \OC\Files\Filesystem::normalizePath($file_path),
 				'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp)));
@@ -675,7 +675,7 @@ class Trashbin {
 			foreach ($files as $file) {
 				if ($availableSpace < 0) {
 					$tmp = self::delete($file['name'], $user, $file['mtime']);
-					\OCP\Util::writeLog('files_trashbin', 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', \OC_log::INFO);
+					\OCP\Util::writeLog('files_trashbin', 'remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', \OCP\Util::INFO);
 					$availableSpace += $tmp;
 					$size += $tmp;
 				} else {
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index c571439640..fc98d80eb0 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -35,14 +35,14 @@ $always = array_key_exists('forceIcon', $_GET) ? (bool)$_GET['forceIcon'] : true
 if ($file === '') {
 	//400 Bad Request
 	\OC_Response::setStatus(400);
-	\OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
+	\OCP\Util::writeLog('core-preview', 'No file parameter was passed', \OCP\Util::DEBUG);
 	exit;
 }
 
 if ($maxX === 0 || $maxY === 0) {
 	//400 Bad Request
 	\OC_Response::setStatus(400);
-	\OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
+	\OCP\Util::writeLog('core-preview', 'x and/or y set to 0', \OCP\Util::DEBUG);
 	exit;
 }
 
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 2f34708fae..a4c7951d83 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -37,10 +37,11 @@ if (OC::checkUpgrade(false)) {
 
 	$l = new \OC_L10N('core');
 	$eventSource = \OC::$server->createEventSource();
+	$logger = \OC::$server->getLogger();
 	$updater = new \OC\Updater(
 			\OC::$server->getHTTPHelper(),
 			\OC::$server->getConfig(),
-			\OC_Log::$object
+			$logger
 	);
 	$incompatibleApps = [];
 	$disabledThirdPartyApps = [];
diff --git a/core/setup/controller.php b/core/setup/controller.php
index f5255fb453..f616ae5a5b 100644
--- a/core/setup/controller.php
+++ b/core/setup/controller.php
@@ -105,7 +105,7 @@ class Controller {
 
 	public function loadAutoConfig($post) {
 		if( file_exists($this->autoConfigFile)) {
-			\OC_Log::write('core', 'Autoconfig file found, setting up ownCloud…', \OC_Log::INFO);
+			\OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', \OCP\Util::INFO);
 			$AUTOCONFIG = array();
 			include $this->autoConfigFile;
 			$post = array_merge ($post, $AUTOCONFIG);
diff --git a/cron.php b/cron.php
index 6ace29650e..987c7dbca7 100644
--- a/cron.php
+++ b/cron.php
@@ -54,7 +54,7 @@ try {
 	// initialize a dummy memory session
 	\OC::$server->setSession(new \OC\Session\Memory(''));
 
-	$logger = \OC_Log::$object;
+	$logger = \OC::$server->getLogger();
 
 	// Don't do anything if ownCloud has not been installed
 	if (!OC_Config::getValue('installed', false)) {
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 7031962fc4..23285f61e7 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -73,7 +73,7 @@ class Autoloader {
 			 * Remove "apps/" from inclusion path for smooth migration to mutli app dir
 			 */
 			if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
-				\OC_Log::write('core', 'include path for class "' . $class . '" starts with "apps/"', \OC_Log::DEBUG);
+				\OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', \OCP\Util::DEBUG);
 				$paths[] = str_replace('apps/', '', \OC::$CLASSPATH[$class]);
 			}
 		} elseif (strpos($class, 'OC_') === 0) {
diff --git a/lib/base.php b/lib/base.php
index 8812d5698f..1766fc38f8 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -572,7 +572,8 @@ class OC {
 		OC_Util::isSetLocaleWorking();
 
 		if (!defined('PHPUNIT_RUN')) {
-			OC\Log\ErrorHandler::setLogger(OC_Log::$object);
+			$logger = \OC::$server->getLogger();
+			OC\Log\ErrorHandler::setLogger($logger);
 			if (defined('DEBUG') and DEBUG) {
 				OC\Log\ErrorHandler::register(true);
 				set_exception_handler(array('OC_Template', 'printExceptionErrorPage'));
@@ -1029,7 +1030,7 @@ class OC {
 		}
 
 		if (defined("DEBUG") && DEBUG) {
-			OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
+			\OCP\Util::writeLog('core', 'Trying to login from cookie', \OCP\Util::DEBUG);
 		}
 
 		if(OC_User::userExists($_COOKIE['oc_username'])) {
@@ -1041,8 +1042,8 @@ class OC {
 				OC_Util::redirectToDefaultPage();
 				// doesn't return
 			}
-			OC_Log::write('core', 'Authentication cookie rejected for user ' .
-				$_COOKIE['oc_username'], OC_Log::WARN);
+			\OCP\Util::writeLog('core', 'Authentication cookie rejected for user ' .
+				$_COOKIE['oc_username'], \OCP\Util::WARN);
 			// if you reach this point you have changed your password
 			// or you are an attacker
 			// we can not delete tokens here because users may reach
diff --git a/lib/private/app.php b/lib/private/app.php
index e45d9ac07b..8062debef5 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -511,7 +511,7 @@ class OC_App {
 			}
 		}
 
-		OC_Log::write('core', 'No application directories are marked as writable.', OC_Log::ERROR);
+		\OCP\Util::writeLog('core', 'No application directories are marked as writable.', \OCP\Util::ERROR);
 		return null;
 	}
 
@@ -771,7 +771,7 @@ class OC_App {
 
 		foreach (OC::$APPSROOTS as $apps_dir) {
 			if (!is_readable($apps_dir['path'])) {
-				OC_Log::write('core', 'unable to read app folder : ' . $apps_dir['path'], OC_Log::WARN);
+				\OCP\Util::writeLog('core', 'unable to read app folder : ' . $apps_dir['path'], \OCP\Util::WARN);
 				continue;
 			}
 			$dh = opendir($apps_dir['path']);
@@ -817,7 +817,7 @@ class OC_App {
 				$info = OC_App::getAppInfo($app);
 
 				if (!isset($info['name'])) {
-					OC_Log::write('core', 'App id "' . $app . '" has no name in appinfo', OC_Log::ERROR);
+					\OCP\Util::writeLog('core', 'App id "' . $app . '" has no name in appinfo', \OCP\Util::ERROR);
 					continue;
 				}
 
@@ -1205,11 +1205,11 @@ class OC_App {
 				}
 				return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
 			} else {
-				OC_Log::write('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', OC_Log::ERROR);
+				\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ', user not logged in', \OCP\Util::ERROR);
 				return false;
 			}
 		} else {
-			OC_Log::write('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'Can\'t get app storage, app ' . $appId . ' not enabled', \OCP\Util::ERROR);
 			return false;
 		}
 	}
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index 69008c7fab..a433b84d7b 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -54,7 +54,7 @@ class File implements ICache {
 			$this->storage = new View('/' . $user->getUID() . '/cache');
 			return $this->storage;
 		} else {
-			\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'Can\'t get cache storage, user not logged in', \OCP\Util::ERROR);
 			throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
 		}
 	}
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index e4f53a219d..18bd3b8d91 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -128,7 +128,7 @@ class File extends Node implements IFile {
 		try {
 			$target = $partStorage->fopen($internalPartPath, 'wb');
 			if ($target === false) {
-				\OC_Log::write('webdav', '\OC\Files\Filesystem::fopen() failed', \OC_Log::ERROR);
+				\OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::fopen() failed', \OCP\Util::ERROR);
 				// because we have no clue about the cause we can only throw back a 500/Internal Server Error
 				throw new Exception('Could not write file contents');
 			}
@@ -192,7 +192,7 @@ class File extends Node implements IFile {
 						$fileExists = $storage->file_exists($internalPath);
 					}
 					if (!$run || $renameOkay === false || $fileExists === false) {
-						\OC_Log::write('webdav', 'renaming part file to final file failed', \OC_Log::ERROR);
+						\OCP\Util::writeLog('webdav', 'renaming part file to final file failed', \OCP\Util::ERROR);
 						throw new Exception('Could not rename part file to final file');
 					}
 				} catch (\Exception $e) {
@@ -366,7 +366,7 @@ class File extends Node implements IFile {
 					$renameOkay = $this->fileView->rename($partFile, $targetPath);
 					$fileExists = $this->fileView->file_exists($targetPath);
 					if ($renameOkay === false || $fileExists === false) {
-						\OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
+						\OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::rename() failed', \OCP\Util::ERROR);
 						// only delete if an error occurred and the target file was already created
 						if ($fileExists) {
 							// set to null to avoid double-deletion when handling exception
diff --git a/lib/private/db.php b/lib/private/db.php
index 98df1c7371..1e93eb1892 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -230,7 +230,7 @@ class OC_DB {
 		try {
 			$result = $schemaManager->updateDbFromStructure($file);
 		} catch (Exception $e) {
-			OC_Log::write('core', 'Failed to update database structure ('.$e.')', OC_Log::FATAL);
+			\OCP\Util::writeLog('core', 'Failed to update database structure ('.$e.')', \OCP\Util::FATAL);
 			throw $e;
 		}
 		return $result;
@@ -247,7 +247,7 @@ class OC_DB {
 		try {
 			$result = $schemaManager->simulateUpdateDbFromStructure($file);
 		} catch (Exception $e) {
-			OC_Log::write('core', 'Simulated database structure update failed ('.$e.')', OC_Log::FATAL);
+			\OCP\Util::writeLog('core', 'Simulated database structure update failed ('.$e.')', \OCP\Util::FATAL);
 			throw $e;
 		}
 		return $result;
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index 2d8ab550a7..a36bd2649d 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -103,7 +103,7 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
 		$statement = $this->adapter->fixupStatement($statement);
 
 		if(\OC_Config::getValue( 'log_query', false)) {
-			\OC_Log::write('core', 'DB prepare : '.$statement, \OC_Log::DEBUG);
+			\OCP\Util::writeLog('core', 'DB prepare : '.$statement, \OCP\Util::DEBUG);
 		}
 		return parent::prepare($statement);
 	}
diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php
index a8fd168d15..4bdaf01f07 100644
--- a/lib/private/db/statementwrapper.php
+++ b/lib/private/db/statementwrapper.php
@@ -66,7 +66,7 @@ class OC_DB_StatementWrapper {
 	public function execute($input=array()) {
 		if(OC_Config::getValue( "log_query", false)) {
 			$params_str = str_replace("\n", " ", var_export($input, true));
-			OC_Log::write('core', 'DB execute with arguments : '.$params_str, OC_Log::DEBUG);
+			\OCP\Util::writeLog('core', 'DB execute with arguments : '.$params_str, \OCP\Util::DEBUG);
 		}
 		$this->lastArguments = $input;
 		if (count($input) > 0) {
diff --git a/lib/private/files.php b/lib/private/files.php
index 17e2e5a398..b61d09d8a0 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -317,9 +317,9 @@ class OC_Files {
 			file_put_contents(OC::$SERVERROOT . '/.htaccess', $htaccess);
 			return OC_Helper::computerFileSize($size);
 		} else {
-			OC_Log::write('files',
+			\OCP\Util::writeLog('files',
 				'Can\'t write upload limit to ' . OC::$SERVERROOT . '/.htaccess. Please check the file permissions',
-				OC_Log::WARN);
+				\OCP\Util::WARN);
 		}
 		return false;
 	}
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 680398e383..8cf097421d 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -120,7 +120,7 @@ class Cache {
 				]);
 				$this->loadMimetypes();
 			} catch (\Doctrine\DBAL\DBALException $e) {
-				\OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG);
+				\OCP\Util::writeLog('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OCP\Util::DEBUG);
 				return -1;
 			}
 		}
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 50609e1e20..7c65c72135 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -355,7 +355,7 @@ class Scanner extends BasicEmitter {
 				// might happen if inserting duplicate while a scanning
 				// process is running in parallel
 				// log and ignore
-				\OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG);
+				\OCP\Util::writeLog('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OCP\Util::DEBUG);
 				$exceptionOccurred = true;
 			} catch (\OCP\Lock\LockedException $e) {
 				if ($this->useTransactions) {
diff --git a/lib/private/files/mount/mountpoint.php b/lib/private/files/mount/mountpoint.php
index f1e492c860..2871bbd908 100644
--- a/lib/private/files/mount/mountpoint.php
+++ b/lib/private/files/mount/mountpoint.php
@@ -140,12 +140,12 @@ class MountPoint implements IMountPoint {
 					// the root storage could not be initialized, show the user!
 					throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception);
 				} else {
-					\OC_Log::write('core', $exception->getMessage(), \OC_Log::ERROR);
+					\OCP\Util::writeLog('core', $exception->getMessage(), \OCP\Util::ERROR);
 				}
 				return null;
 			}
 		} else {
-			\OC_Log::write('core', 'storage backend ' . $this->class . ' not found', \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', \OCP\Util::ERROR);
 			$this->invalidStorage = true;
 			return null;
 		}
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index 839fb81d5a..b7272b7d1f 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -203,17 +203,17 @@ class Local extends \OC\Files\Storage\Common {
 		$dstParent = dirname($path2);
 
 		if (!$this->isUpdatable($srcParent)) {
-			\OC_Log::write('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OCP\Util::ERROR);
 			return false;
 		}
 
 		if (!$this->isUpdatable($dstParent)) {
-			\OC_Log::write('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OCP\Util::ERROR);
 			return false;
 		}
 
 		if (!$this->file_exists($path1)) {
-			\OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, \OCP\Util::ERROR);
 			return false;
 		}
 
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 1706818f03..cb3c05d2bc 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -848,7 +848,7 @@ class View {
 				$hooks[] = 'write';
 				break;
 			default:
-				\OC_Log::write('core', 'invalid mode (' . $mode . ') for ' . $path, \OC_Log::ERROR);
+				\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, \OCP\Util::ERROR);
 		}
 
 		return $this->basicOperation('fopen', $path, $hooks, $mode);
diff --git a/lib/private/hook.php b/lib/private/hook.php
index 188c3d65ac..faf5495b64 100644
--- a/lib/private/hook.php
+++ b/lib/private/hook.php
@@ -111,9 +111,9 @@ class OC_Hook{
 				if (empty($message)) {
 					$message = get_class($e);
 				}
-				OC_Log::write('hook',
+				\OCP\Util::writeLog('hook',
 					'error while running hook (' . $class . '::' . $i["name"] . '): ' . $message,
-					OC_Log::ERROR);
+					\OCP\Util::ERROR);
 				if($e instanceof \OC\ServerNotAvailableException) {
 					throw $e;
 				}
diff --git a/lib/private/installer.php b/lib/private/installer.php
index bd214be566..2da525d3ed 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -480,7 +480,7 @@ class OC_Installer{
 
 			return true;
 		}else{
-			OC_Log::write('core', 'can\'t remove app '.$name.'. It is not installed.', OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'can\'t remove app '.$name.'. It is not installed.', \OCP\Util::ERROR);
 
 			return false;
 		}
diff --git a/lib/private/legacy/log.php b/lib/private/legacy/log.php
deleted file mode 100644
index f9a2044da7..0000000000
--- a/lib/private/legacy/log.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-/**
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * logging utilities
- *
- * Log is saved by default at data/owncloud.log using OC_Log_Owncloud.
- * Selecting other backend is done with a config option 'log_type'.
- */
-
-OC_Log::$object = new \OC\Log();
-/**
- * @deprecated use \OC::$server->getLogger() to get an \OCP\ILogger instance
- */
-class OC_Log {
-	public static $object;
-
-	const DEBUG=0;
-	const INFO=1;
-	const WARN=2;
-	const ERROR=3;
-	const FATAL=4;
-
-	static private $level_funcs = array(
-		self::DEBUG	=> 'debug',
-		self::INFO	=> 'info',
-		self::WARN	=> 'warning',
-		self::ERROR	=> 'error',
-		self::FATAL	=> 'emergency',
-		);
-
-	static public $enabled = true;
-	static protected $class = null;
-
-	/**
-	 * write a message in the log
-	 * @param string $app
-	 * @param string $message
-	 * @param int $level
-	 */
-	public static function write($app, $message, $level) {
-		if (self::$enabled) {
-			$context = array('app' => $app);
-			$func = array(self::$object, self::$level_funcs[$level]);
-			call_user_func($func, $message, $context);
-		}
-	}
-}
diff --git a/lib/private/log.php b/lib/private/log.php
index dd5cb6efbb..3c0e7b45d1 100644
--- a/lib/private/log.php
+++ b/lib/private/log.php
@@ -79,7 +79,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function emergency($message, array $context = array()) {
-		$this->log(\OC_Log::FATAL, $message, $context);
+		$this->log(\OCP\Util::FATAL, $message, $context);
 	}
 
 	/**
@@ -92,7 +92,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function alert($message, array $context = array()) {
-		$this->log(\OC_Log::ERROR, $message, $context);
+		$this->log(\OCP\Util::ERROR, $message, $context);
 	}
 
 	/**
@@ -104,7 +104,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function critical($message, array $context = array()) {
-		$this->log(\OC_Log::ERROR, $message, $context);
+		$this->log(\OCP\Util::ERROR, $message, $context);
 	}
 
 	/**
@@ -115,7 +115,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function error($message, array $context = array()) {
-		$this->log(\OC_Log::ERROR, $message, $context);
+		$this->log(\OCP\Util::ERROR, $message, $context);
 	}
 
 	/**
@@ -128,7 +128,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function warning($message, array $context = array()) {
-		$this->log(\OC_Log::WARN, $message, $context);
+		$this->log(\OCP\Util::WARN, $message, $context);
 	}
 
 	/**
@@ -138,7 +138,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function notice($message, array $context = array()) {
-		$this->log(\OC_Log::INFO, $message, $context);
+		$this->log(\OCP\Util::INFO, $message, $context);
 	}
 
 	/**
@@ -150,7 +150,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function info($message, array $context = array()) {
-		$this->log(\OC_Log::INFO, $message, $context);
+		$this->log(\OCP\Util::INFO, $message, $context);
 	}
 
 	/**
@@ -160,7 +160,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function debug($message, array $context = array()) {
-		$this->log(\OC_Log::DEBUG, $message, $context);
+		$this->log(\OCP\Util::DEBUG, $message, $context);
 	}
 
 
@@ -172,7 +172,7 @@ class Log implements ILogger {
 	 * @param array $context
 	 */
 	public function log($level, $message, array $context = array()) {
-		$minLevel = min($this->config->getValue('loglevel', \OC_Log::WARN), \OC_Log::ERROR);
+		$minLevel = min($this->config->getValue('loglevel', \OCP\Util::WARN), \OCP\Util::ERROR);
 		$logCondition = $this->config->getValue('log.condition', []);
 
 		if (isset($context['app'])) {
@@ -185,7 +185,7 @@ class Log implements ILogger {
 			if(!empty($logCondition)
 				&& isset($logCondition['apps'])
 				&& in_array($app, $logCondition['apps'], true)) {
-				$minLevel = \OC_Log::DEBUG;
+				$minLevel = \OCP\Util::DEBUG;
 			}
 
 		} else {
@@ -233,7 +233,7 @@ class Log implements ILogger {
 
 		// if log condition is satisfied change the required log level to DEBUG
 		if($this->logConditionSatisfied) {
-			$minLevel = \OC_Log::DEBUG;
+			$minLevel = \OCP\Util::DEBUG;
 		}
 
 		if ($level >= $minLevel) {
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index 01112ef7f9..c98f21208b 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -78,8 +78,8 @@ class OC_Log_Owncloud {
 		$remoteAddr = $request->getRemoteAddress();
 		// remove username/passwords from URLs before writing the to the log file
 		$time = $time->format($format);
-		$minLevel=min($config->getValue( "loglevel", OC_Log::WARN ), OC_Log::ERROR);
-		if($minLevel == OC_Log::DEBUG) {
+		$minLevel=min($config->getValue( "loglevel", \OCP\Util::WARN ), \OCP\Util::ERROR);
+		if($minLevel == \OCP\Util::DEBUG) {
 			$url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '--';
 			$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '--';
 			$entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time', 'method', 'url');
@@ -107,7 +107,7 @@ class OC_Log_Owncloud {
 	 */
 	public static function getEntries($limit=50, $offset=0) {
 		self::init();
-		$minLevel=OC_Config::getValue( "loglevel", OC_Log::WARN );
+		$minLevel=OC_Config::getValue( "loglevel", \OCP\Util::WARN );
 		$entries = array();
 		$handle = @fopen(self::$logFile, 'rb');
 		if ($handle) {
diff --git a/lib/private/log/rotate.php b/lib/private/log/rotate.php
index a8882e0e2f..4572a9904d 100644
--- a/lib/private/log/rotate.php
+++ b/lib/private/log/rotate.php
@@ -44,6 +44,6 @@ class Rotate extends \OC\BackgroundJob\Job {
 		$rotatedLogfile = $logfile.'.1';
 		rename($logfile, $rotatedLogfile);
 		$msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"';
-		\OC_Log::write('OC\Log\Rotate', $msg, \OC_Log::WARN);
+		\OCP\Util::writeLog('OC\Log\Rotate', $msg, \OCP\Util::WARN);
 	}
 }
diff --git a/lib/private/log/syslog.php b/lib/private/log/syslog.php
index 863d1d6c20..cb42c1dc01 100644
--- a/lib/private/log/syslog.php
+++ b/lib/private/log/syslog.php
@@ -23,11 +23,11 @@
 
 class OC_Log_Syslog {
 	static protected $levels = array(
-		OC_Log::DEBUG => LOG_DEBUG,
-		OC_Log::INFO => LOG_INFO,
-		OC_Log::WARN => LOG_WARNING,
-		OC_Log::ERROR => LOG_ERR,
-		OC_Log::FATAL => LOG_CRIT,
+		\OCP\Util::DEBUG => LOG_DEBUG,
+		\OCP\Util::INFO => LOG_INFO,
+		\OCP\Util::WARN => LOG_WARNING,
+		\OCP\Util::ERROR => LOG_ERR,
+		\OCP\Util::FATAL => LOG_CRIT,
 	);
 
 	/**
diff --git a/lib/private/naturalsort.php b/lib/private/naturalsort.php
index 310a029b6d..26b9cec6cf 100644
--- a/lib/private/naturalsort.php
+++ b/lib/private/naturalsort.php
@@ -39,7 +39,7 @@ class NaturalSort {
 		// or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator
 		if (isset($injectedCollator)) {
 			$this->collator = $injectedCollator;
-			\OC_Log::write('core', 'forced use of '.get_class($injectedCollator), \OC_Log::DEBUG);
+			\OCP\Util::writeLog('core', 'forced use of '.get_class($injectedCollator), \OCP\Util::DEBUG);
 		}
 	}
 
diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php
index 18ba4cea00..d6593e5089 100644
--- a/lib/private/ocsclient.php
+++ b/lib/private/ocsclient.php
@@ -272,7 +272,7 @@ class OCSClient {
 
 		$tmp = $data->data->content;
 		if (is_null($tmp)) {
-			\OC_Log::write('core', 'No update found at the ownCloud appstore for app ' . $id, \OC_Log::INFO);
+			\OCP\Util::writeLog('core', 'No update found at the ownCloud appstore for app ' . $id, \OCP\Util::INFO);
 			return null;
 		}
 
diff --git a/lib/private/preview.php b/lib/private/preview.php
index cc954bc365..5dcab476a4 100644
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -135,7 +135,7 @@ class Preview {
 			&& \OC::$server->getConfig()
 						   ->getSystemValue('enable_previews', true)
 		) {
-			\OC_Log::write('core', 'No preview providers exist', \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'No preview providers exist', \OCP\Util::ERROR);
 			throw new \Exception('No preview providers');
 		}
 	}
diff --git a/lib/private/preview/bitmap.php b/lib/private/preview/bitmap.php
index 12ad4f020e..065425c9a1 100644
--- a/lib/private/preview/bitmap.php
+++ b/lib/private/preview/bitmap.php
@@ -46,7 +46,7 @@ abstract class Bitmap extends Provider {
 		try {
 			$bp = $this->getResizedPreview($tmpPath, $maxX, $maxY);
 		} catch (\Exception $e) {
-			\OC_Log::write('core', 'ImageMagick says: ' . $e->getmessage(), \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', 'ImageMagick says: ' . $e->getmessage(), \OCP\Util::ERROR);
 			return false;
 		}
 
diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php
index f72c5def35..30398147aa 100644
--- a/lib/private/preview/office.php
+++ b/lib/private/preview/office.php
@@ -56,7 +56,7 @@ abstract class Office extends Provider {
 		} catch (\Exception $e) {
 			unlink($absPath);
 			unlink($pdfPreview);
-			\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
 			return false;
 		}
 
diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php
index 4e3cba576f..f8318e9a69 100644
--- a/lib/private/preview/svg.php
+++ b/lib/private/preview/svg.php
@@ -52,7 +52,7 @@ class SVG extends Provider {
 			$svg->readImageBlob($content);
 			$svg->setImageFormat('png32');
 		} catch (\Exception $e) {
-			\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
+			\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
 			return false;
 		}
 
diff --git a/lib/private/setup/mssql.php b/lib/private/setup/mssql.php
index f8815259af..0ae02d6cbc 100644
--- a/lib/private/setup/mssql.php
+++ b/lib/private/setup/mssql.php
@@ -66,7 +66,7 @@ class MSSQL extends AbstractDatabase {
 				$entry = '';
 			}
 			$entry.='Offending command was: '.$query.'<br />';
-			\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 		} else {
 			$row = sqlsrv_fetch_array($result);
 
@@ -77,7 +77,7 @@ class MSSQL extends AbstractDatabase {
 					$entry = '';
 				}
 				$entry.='Offending command was: '.$query.'<br />';
-				\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 			} else {
 				if ($row == null) {
 					$query = "CREATE LOGIN [".$this->dbuser."] WITH PASSWORD = '".$this->dbpassword."';";
@@ -89,7 +89,7 @@ class MSSQL extends AbstractDatabase {
 							$entry = '';
 						}
 						$entry.='Offending command was: '.$query.'<br />';
-						\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+						\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 					}
 				}
 			}
@@ -106,7 +106,7 @@ class MSSQL extends AbstractDatabase {
 				$entry = '';
 			}
 			$entry.='Offending command was: '.$query.'<br />';
-			\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 		} else {
 			$row = sqlsrv_fetch_array($result);
 
@@ -117,7 +117,7 @@ class MSSQL extends AbstractDatabase {
 					$entry = '';
 				}
 				$entry.='Offending command was: '.$query.'<br />';
-				\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 			} else {
 				if ($row == null) {
 					$query = "USE [".$this->dbname."]; CREATE USER [".$this->dbuser."] FOR LOGIN [".$this->dbuser."];";
@@ -129,7 +129,7 @@ class MSSQL extends AbstractDatabase {
 							$entry = '';
 						}
 						$entry.='Offending command was: '.$query.'<br />';
-						\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+						\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 					}
 				}
 
@@ -142,7 +142,7 @@ class MSSQL extends AbstractDatabase {
 						$entry = '';
 					}
 					$entry.='Offending command was: '.$query.'<br />';
-					\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+					\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 				}
 			}
 		}
@@ -158,7 +158,7 @@ class MSSQL extends AbstractDatabase {
 				$entry = '';
 			}
 			$entry.='Offending command was: '.$query.'<br />';
-			\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 		}
 	}
 
@@ -179,7 +179,7 @@ class MSSQL extends AbstractDatabase {
 				$entry = '';
 			}
 			$entry.='Offending command was: '.$query.'<br />';
-			\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 		} else {
 			$row = sqlsrv_fetch_array($result);
 
@@ -190,7 +190,7 @@ class MSSQL extends AbstractDatabase {
 					$entry = '';
 				}
 				$entry.='Offending command was: '.$query.'<br />';
-				\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 			} else {
 				if ($row == null) {
 					\OC_DB::createDbFromStructure($this->dbDefinitionFile);
diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php
index b9246a915a..c01ff724b8 100644
--- a/lib/private/setup/mysql.php
+++ b/lib/private/setup/mysql.php
@@ -103,7 +103,7 @@ class MySQL extends AbstractDatabase {
 		if(!$result) {
 			$entry = $this->trans->t('DB Error: "%s"', array(mysql_error($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.mssql', $entry, \OCP\Util::WARN);
 		}
 		$query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
 
diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php
index 791dc7232f..d46d5529da 100644
--- a/lib/private/setup/oci.php
+++ b/lib/private/setup/oci.php
@@ -66,7 +66,7 @@ class OCI extends AbstractDatabase {
 		} else {
 			$easy_connect_string = '//'.$e_host.'/'.$e_dbname;
 		}
-		\OC_Log::write('setup oracle', 'connect string: ' . $easy_connect_string, \OC_Log::DEBUG);
+		\OCP\Util::writeLog('setup oracle', 'connect string: ' . $easy_connect_string, \OCP\Util::DEBUG);
 		$connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string);
 		if(!$connection) {
 			$errorMessage = $this->getLastError();
@@ -93,7 +93,7 @@ class OCI extends AbstractDatabase {
 		if (!$stmt) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 		$result = oci_execute($stmt);
 		if($result) {
@@ -155,7 +155,7 @@ class OCI extends AbstractDatabase {
 		if (!$stmt) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 		$result = oci_execute($stmt);
 
@@ -178,14 +178,14 @@ class OCI extends AbstractDatabase {
 		if (!$stmt) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 		oci_bind_by_name($stmt, ':un', $name);
 		$result = oci_execute($stmt);
 		if(!$result) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 
 		if(! oci_fetch_row($stmt)) {
@@ -196,7 +196,7 @@ class OCI extends AbstractDatabase {
 			if (!$stmt) {
 				$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 			}
 			//oci_bind_by_name($stmt, ':un', $name);
 			$result = oci_execute($stmt);
@@ -204,7 +204,7 @@ class OCI extends AbstractDatabase {
 				$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
 					array($query, $name, $password)) . '<br />';
-				\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 			}
 		} else { // change password of the existing role
 			$query = "ALTER USER :un IDENTIFIED BY :pw";
@@ -212,7 +212,7 @@ class OCI extends AbstractDatabase {
 			if (!$stmt) {
 				$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 			}
 			oci_bind_by_name($stmt, ':un', $name);
 			oci_bind_by_name($stmt, ':pw', $password);
@@ -220,7 +220,7 @@ class OCI extends AbstractDatabase {
 			if(!$result) {
 				$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 			}
 		}
 		// grant necessary roles
@@ -229,14 +229,14 @@ class OCI extends AbstractDatabase {
 		if (!$stmt) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 		$result = oci_execute($stmt);
 		if(!$result) {
 			$entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
 				array($query, $name, $password)) . '<br />';
-			\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.oci', $entry, \OCP\Util::WARN);
 		}
 	}
 
diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php
index 597e38f43a..c8fd3b98fe 100644
--- a/lib/private/setup/postgresql.php
+++ b/lib/private/setup/postgresql.php
@@ -118,7 +118,7 @@ class PostgreSQL extends AbstractDatabase {
 		if(!$result) {
 			$entry = $this->trans->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.pg', $entry, \OCP\Util::WARN);
 		}
 		if(! pg_fetch_row($result)) {
 			//The database does not exists... let's create it
@@ -127,7 +127,7 @@ class PostgreSQL extends AbstractDatabase {
 			if(!$result) {
 				$entry = $this->trans->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.pg', $entry, \OCP\Util::WARN);
 			}
 			else {
 				$query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC";
@@ -144,7 +144,7 @@ class PostgreSQL extends AbstractDatabase {
 		if(!$result) {
 			$entry = $this->trans->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
 			$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-			\OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
+			\OCP\Util::writeLog('setup.pg', $entry, \OCP\Util::WARN);
 		}
 
 		if(! pg_fetch_row($result)) {
@@ -154,7 +154,7 @@ class PostgreSQL extends AbstractDatabase {
 			if(!$result) {
 				$entry = $this->trans->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.pg', $entry, \OCP\Util::WARN);
 			}
 		}
 		else { // change password of the existing role
@@ -163,7 +163,7 @@ class PostgreSQL extends AbstractDatabase {
 			if(!$result) {
 				$entry = $this->trans->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
 				$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
-				\OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
+				\OCP\Util::writeLog('setup.pg', $entry, \OCP\Util::WARN);
 			}
 		}
 	}
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index af7f78b9ff..5d2e3b74da 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -87,10 +87,10 @@ class Share extends Constants {
 				}
 				return true;
 			}
-			\OC_Log::write('OCP\Share',
+			\OCP\Util::writeLog('OCP\Share',
 				'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class']
 				.' is already registered for '.$itemType,
-				\OC_Log::WARN);
+				\OCP\Util::WARN);
 		}
 		return false;
 	}
@@ -153,7 +153,7 @@ class Share extends Constants {
 			$result = $query->execute(array($source, self::SHARE_TYPE_USER));
 
 			if (\OCP\DB::isError($result)) {
-				\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
 			} else {
 				while ($row = $result->fetchRow()) {
 					$shares[] = $row['share_with'];
@@ -175,7 +175,7 @@ class Share extends Constants {
 			$result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
 
 			if (\OCP\DB::isError($result)) {
-				\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
 			} else {
 				while ($row = $result->fetchRow()) {
 					$usersInGroup = \OC_Group::usersInGroup($row['share_with']);
@@ -256,7 +256,7 @@ class Share extends Constants {
 				$result = $query->execute();
 
 				if (\OCP\DB::isError($result)) {
-					\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
 				} else {
 					while ($row = $result->fetchRow()) {
 						foreach ($fileTargets[$row['fileid']] as $uid => $shareData) {
@@ -464,7 +464,7 @@ class Share extends Constants {
 		$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
 		$result = $query->execute(array($token));
 		if (\OC_DB::isError($result)) {
-			\OC_Log::write('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OC_Log::ERROR);
+			\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
 		}
 		$row = $result->fetchRow();
 		if ($row === false) {
@@ -581,7 +581,7 @@ class Share extends Constants {
 		if ($backend->isShareTypeAllowed($shareType) === false) {
 			$message = 'Sharing %s failed, because the backend does not allow shares from type %i';
 			$message_t = $l->t('Sharing %s failed, because the backend does not allow shares from type %i', array($itemSourceName, $shareType));
-			\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareType), \OC_Log::ERROR);
+			\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareType), \OCP\Util::ERROR);
 			throw new \Exception($message_t);
 		}
 
@@ -599,14 +599,14 @@ class Share extends Constants {
 			if (!$path) {
 				$message = 'Sharing %s failed, because the file does not exist';
 				$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			// verify that the user has share permission
 			if (!\OC\Files\Filesystem::isSharable($path)) {
 				$message = 'You are not allowed to share %s';
 				$message_t = $l->t('You are not allowed to share %s', array($itemSourceName));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 		}
@@ -619,7 +619,7 @@ class Share extends Constants {
 			foreach ($mounts as $mount) {
 				if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
 					$message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!';
-					\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::ERROR);
 					throw new \Exception($message);
 				}
 
@@ -636,13 +636,13 @@ class Share extends Constants {
 			if ($shareWith == $uidOwner) {
 				$message = 'Sharing %s failed, because the user %s is the item owner';
 				$message_t = $l->t('Sharing %s failed, because the user %s is the item owner', array($itemSourceName, $shareWith));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			if (!\OC_User::userExists($shareWith)) {
 				$message = 'Sharing %s failed, because the user %s does not exist';
 				$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			if ($shareWithinGroupOnly) {
@@ -651,7 +651,7 @@ class Share extends Constants {
 					$message = 'Sharing %s failed, because the user '
 						.'%s is not a member of any groups that %s is a member of';
 					$message_t = $l->t('Sharing %s failed, because the user %s is not a member of any groups that %s is a member of', array($itemSourceName, $shareWith, $uidOwner));
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith, $uidOwner), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith, $uidOwner), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 			}
@@ -664,7 +664,7 @@ class Share extends Constants {
 				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
 					$message = 'Sharing %s failed, because this item is already shared with %s';
 					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 			}
@@ -672,14 +672,14 @@ class Share extends Constants {
 			if (!\OC_Group::groupExists($shareWith)) {
 				$message = 'Sharing %s failed, because the group %s does not exist';
 				$message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			if ($shareWithinGroupOnly && !\OC_Group::inGroup($uidOwner, $shareWith)) {
 				$message = 'Sharing %s failed, because '
 					.'%s is not a member of the group %s';
 				$message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			// Check if the item source is already shared with the group, either from the same owner or a different user
@@ -692,7 +692,7 @@ class Share extends Constants {
 				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
 					$message = 'Sharing %s failed, because this item is already shared with %s';
 					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 			}
@@ -731,7 +731,7 @@ class Share extends Constants {
 				if (\OCP\Util::isPublicLinkPasswordRequired() && empty($shareWith)) {
 					$message = 'You need to provide a password to create a public link, only protected links are allowed';
 					$message_t = $l->t('You need to provide a password to create a public link, only protected links are allowed');
-					\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 
@@ -760,7 +760,7 @@ class Share extends Constants {
 			}
 			$message = 'Sharing %s failed, because sharing with links is not allowed';
 			$message_t = $l->t('Sharing %s failed, because sharing with links is not allowed', array($itemSourceName));
-			\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
+			\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::ERROR);
 			throw new \Exception($message_t);
 		} else if ($shareType === self::SHARE_TYPE_REMOTE) {
 			$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER .
@@ -787,7 +787,7 @@ class Share extends Constants {
 			// Future share types need to include their own conditions
 			$message = 'Share type %s is not valid for %s';
 			$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource));
-			\OC_Log::write('OCP\Share', sprintf($message, $shareType, $itemSource), \OC_Log::ERROR);
+			\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::ERROR);
 			throw new \Exception($message_t);
 		}
 
@@ -988,7 +988,7 @@ class Share extends Constants {
 		$result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient));
 
 		if($result === false) {
-			\OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR);
+			\OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', \OCP\Util::ERROR);
 		}
 	}
 
@@ -1015,7 +1015,7 @@ class Share extends Constants {
 					$message = 'Setting permissions for %s failed,'
 						.' because the permissions exceed permissions granted to %s';
 					$message_t = $l->t('Setting permissions for %s failed, because the permissions exceed permissions granted to %s', array($itemSource, \OC_User::getUser()));
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSource, \OC_User::getUser()), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, \OC_User::getUser()), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 			}
@@ -1078,7 +1078,7 @@ class Share extends Constants {
 		$message = 'Setting permissions for %s failed, because the item was not found';
 		$message_t = $l->t('Setting permissions for %s failed, because the item was not found', array($itemSource));
 
-		\OC_Log::write('OCP\Share', sprintf($message, $itemSource), \OC_Log::ERROR);
+		\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::ERROR);
 		throw new \Exception($message_t);
 	}
 
@@ -1340,20 +1340,20 @@ class Share extends Constants {
 				if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
 					$message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
 					$message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class));
-					\OC_Log::write('OCP\Share', sprintf($message, $class), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 				return self::$backends[$itemType];
 			} else {
 				$message = 'Sharing backend %s not found';
 				$message_t = $l->t('Sharing backend %s not found', array($class));
-				\OC_Log::write('OCP\Share', sprintf($message, $class), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 		}
 		$message = 'Sharing backend for %s not found';
 		$message_t = $l->t('Sharing backend for %s not found', array($itemType));
-		\OC_Log::write('OCP\Share', sprintf($message, $itemType), \OC_Log::ERROR);
+		\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), \OCP\Util::ERROR);
 		throw new \Exception($message_t);
 	}
 
@@ -1617,9 +1617,9 @@ class Share extends Constants {
 		$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit);
 		$result = $query->execute($queryArgs);
 		if (\OC_DB::isError($result)) {
-			\OC_Log::write('OCP\Share',
+			\OCP\Util::writeLog('OCP\Share',
 				\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
-				\OC_Log::ERROR);
+				\OCP\Util::ERROR);
 		}
 		$items = array();
 		$targets = array();
@@ -1681,9 +1681,9 @@ class Share extends Constants {
 					$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
 					$parentResult = $query->execute(array($row['parent']));
 					if (\OC_DB::isError($result)) {
-						\OC_Log::write('OCP\Share', 'Can\'t select parent: ' .
+						\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
 							\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
-							\OC_Log::ERROR);
+							\OCP\Util::ERROR);
 					} else {
 						$parentRow = $parentResult->fetchRow();
 						$tmpPath = $parentRow['file_target'];
@@ -2124,7 +2124,7 @@ class Share extends Constants {
 				$message = 'Sharing %s failed, because the user %s is the original sharer';
 				$message_t = $l->t('Sharing %s failed, because the user %s is the original sharer', array($itemSourceName, $shareWith));
 
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 		}
@@ -2136,7 +2136,7 @@ class Share extends Constants {
 					$message = 'Sharing %s failed, because the permissions exceed permissions granted to %s';
 					$message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner));
 
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				} else {
 					// TODO Don't check if inside folder
@@ -2162,7 +2162,7 @@ class Share extends Constants {
 				$message = 'Sharing %s failed, because resharing is not allowed';
 				$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName));
 
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSourceName), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 		} else {
@@ -2175,7 +2175,7 @@ class Share extends Constants {
 				$message = 'Sharing %s failed, because the sharing backend for '
 					.'%s could not find its source';
 				$message_t = $l->t('Sharing %s failed, because the sharing backend for %s could not find its source', array($itemSource, $itemType));
-				\OC_Log::write('OCP\Share', sprintf($message, $itemSource, $itemType), \OC_Log::ERROR);
+				\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource, $itemType), \OCP\Util::ERROR);
 				throw new \Exception($message_t);
 			}
 			if ($backend instanceof \OCP\Share_Backend_File_Dependent) {
@@ -2190,7 +2190,7 @@ class Share extends Constants {
 					$message = 'Sharing %s failed, because the file could not be found in the file cache';
 					$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource));
 
-					\OC_Log::write('OCP\Share', sprintf($message, $itemSource), \OC_Log::ERROR);
+					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::ERROR);
 					throw new \Exception($message_t);
 				}
 			} else {
diff --git a/lib/private/user.php b/lib/private/user.php
index 7c3cb528a9..1d8b89e273 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -142,12 +142,12 @@ class OC_User {
 				case 'database':
 				case 'mysql':
 				case 'sqlite':
-					OC_Log::write('core', 'Adding user backend ' . $backend . '.', OC_Log::DEBUG);
+					\OCP\Util::writeLog('core', 'Adding user backend ' . $backend . '.', \OCP\Util::DEBUG);
 					self::$_usedBackends[$backend] = new OC_User_Database();
 					self::getManager()->registerBackend(self::$_usedBackends[$backend]);
 					break;
 				default:
-					OC_Log::write('core', 'Adding default user backend ' . $backend . '.', OC_Log::DEBUG);
+					\OCP\Util::writeLog('core', 'Adding default user backend ' . $backend . '.', \OCP\Util::DEBUG);
 					$className = 'OC_USER_' . strToUpper($backend);
 					self::$_usedBackends[$backend] = new $className();
 					self::getManager()->registerBackend(self::$_usedBackends[$backend]);
@@ -184,10 +184,10 @@ class OC_User {
 					self::useBackend($backend);
 					self::$_setupedBackends[] = $i;
 				} else {
-					OC_Log::write('core', 'User backend ' . $class . ' already initialized.', OC_Log::DEBUG);
+					\OCP\Util::writeLog('core', 'User backend ' . $class . ' already initialized.', \OCP\Util::DEBUG);
 				}
 			} else {
-				OC_Log::write('core', 'User backend ' . $class . ' not found.', OC_Log::ERROR);
+				\OCP\Util::writeLog('core', 'User backend ' . $class . ' not found.', \OCP\Util::ERROR);
 			}
 		}
 	}
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index 3cf73f939e..081066398c 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -211,7 +211,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
 			$result = $query->execute(array($uid));
 
 			if (OC_DB::isError($result)) {
-				OC_Log::write('core', OC_DB::getErrorMessage(), OC_Log::ERROR);
+				\OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR);
 				return false;
 			}
 
@@ -288,7 +288,7 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
 		$query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
 		$result = $query->execute();
 		if (OC_DB::isError($result)) {
-			OC_Log::write('core', OC_DB::getErrorMessage(), OC_Log::ERROR);
+			\OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR);
 			return false;
 		}
 		return $result->fetchOne();
diff --git a/lib/private/util.php b/lib/private/util.php
index 1558a06f7f..8dbb262214 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -1345,7 +1345,7 @@ class OC_Util {
 		// XCache
 		if (function_exists('xcache_clear_cache')) {
 			if (ini_get('xcache.admin.enable_auth')) {
-				OC_Log::write('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OC_Log::WARN);
+				\OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN);
 			} else {
 				@xcache_clear_cache(XC_TYPE_PHP, 0);
 			}
diff --git a/lib/public/util.php b/lib/public/util.php
index 087bb63961..76f0ea24b4 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -149,7 +149,7 @@ class Util {
 	 */
 	public static function writeLog( $app, $message, $level ) {
 		// call the internal log class
-		\OC_LOG::write( $app, $message, $level );
+		\OCP\Util::writeLog( $app, $message, $level );
 	}
 
 	/**
diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php
index 69b186bb9f..55298430e2 100644
--- a/settings/ajax/enableapp.php
+++ b/settings/ajax/enableapp.php
@@ -31,6 +31,6 @@ try {
 	OC_App::enable(OC_App::cleanAppId((string)$_POST['appid']), $groups);
 	OC_JSON::success();
 } catch (Exception $e) {
-	OC_Log::write('core', $e->getMessage(), OC_Log::ERROR);
+	\OCP\Util::writeLog('core', $e->getMessage(), \OCP\Util::ERROR);
 	OC_JSON::error(array("data" => array("message" => $e->getMessage()) ));
 }
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 085eb2069c..e4ba135b59 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -17,4 +17,4 @@ if (!class_exists('PHPUnit_Framework_TestCase')) {
 }
 
 OC_Hook::clear();
-OC_Log::$enabled = false;
+\OCP\Util::$enabled = false;
diff --git a/tests/lib/logger.php b/tests/lib/logger.php
index 9a9f5be12f..c8566988cf 100644
--- a/tests/lib/logger.php
+++ b/tests/lib/logger.php
@@ -40,7 +40,7 @@ class Logger extends TestCase {
 		$this->config->expects($this->any())
 			->method('getValue')
 			->will(($this->returnValueMap([
-				['loglevel', \OC_Log::WARN, \OC_Log::WARN],
+				['loglevel', \OCP\Util::WARN, \OCP\Util::WARN],
 				['log.condition', [], ['apps' => ['files']]]
 			])));
 		$logger = $this->logger;
-- 
GitLab