diff --git a/includes/main/WebUI.php b/includes/main/WebUI.php
index 16d55b722099638f2326948b83f4ff5389b68cdb..6f3a8dce473bc1ebd1fc966d2e2b5227976cbafe 100644
--- a/includes/main/WebUI.php
+++ b/includes/main/WebUI.php
@@ -22,15 +22,15 @@ class Vtiger_WebUI extends Vtiger_EntryPoint {
 	 * @throws AppException
 	 */
 	protected function checkLogin (Vtiger_Request $request) {
-		 if (!$this->hasLogin()) {
-			    $return_params = $_SERVER['QUERY_STRING'];
-                 if($return_params && !$_SESSION['return_params']) {
-                    //Take the url that user would like to redirect after they have successfully logged in.
-                    $return_params = urlencode($return_params);
-                    Vtiger_Session::set('return_params', $return_params);
-                }
-                header ('Location: index.php');
-                throw new AppException('Login is required');
+		if (!$this->hasLogin()) {
+			$return_params = $_SERVER['QUERY_STRING'];
+            if($return_params && !$_SESSION['return_params']) {
+                //Take the url that user would like to redirect after they have successfully logged in.
+                $return_params = urlencode($return_params);
+                Vtiger_Session::set('return_params', $return_params);
+            }
+            header ('Location: index.php');
+            throw new AppException('Login is required');
 		}
 	}
 
@@ -208,8 +208,9 @@ class Vtiger_WebUI extends Vtiger_EntryPoint {
 			}
 		} catch(Exception $e) {
 			if ($view) {
-				// Log for developement.
-				error_log($e->getTraceAsString(), E_NOTICE);
+				// log for development
+				global $log;
+				$log->debug($e->getMessage().":".$e->getTraceAsString());
 
 				$viewer = new Vtiger_Viewer();
 				$viewer->assign('MESSAGE', $e->getMessage());