commit 0917eae7123e93244fe0599b8eb8a356bb04cad0
Author: Tomáš Šimandl <tomas.simandl@gmail.com>
Date:   Thu Nov 29 21:36:02 2018 +0100

    #7 Use SLF4J logger
    
    - added some log messages

diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/ShowGraph.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/ShowGraph.java
index 44b663c..cebae55 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/ShowGraph.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/ShowGraph.java
@@ -1,5 +1,8 @@
 package cz.zcu.kiv.offscreen.servlets;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -11,12 +14,16 @@ import java.io.IOException;
  * @author Jindra PavlĂ­kovĂˇ <jindra.pav2@seznam.cz>
  */
 public class ShowGraph extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        logger.debug("Processing request");
+
         // render
         RequestDispatcher rd = getServletContext().getRequestDispatcher("/showGraph.jsp");
         rd.forward(request, response);
+        logger.debug("Request processed");
     }
 
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
index c4ff723..aed098c 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/UploadFiles.java
@@ -4,6 +4,8 @@ import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.storage.FileLoader;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.Diagram;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
@@ -19,14 +21,17 @@ import java.util.Map;
  * @author Jindra PavlĂ­kovĂˇ <jindra.pav2@seznam.cz>
  */
 public class UploadFiles extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        logger.debug("Processing request");
         DB db = new DB(getServletContext());
         Diagram diagram = new Diagram(db);
 
         List<Map<String, String>> userDiagramList = new ArrayList<>();
         if (isLoggedIn(request)) {
+            logger.debug("Logged user");
             int loggedUserId = getUserId(request);
 
             userDiagramList = diagram.getDiagramListByUserId(loggedUserId);
@@ -39,24 +44,30 @@ public class UploadFiles extends BaseServlet {
         // render
         RequestDispatcher rd = getServletContext().getRequestDispatcher("/uploadFiles.jsp");
         rd.forward(request, response);
+        logger.debug("Request processed");
     }
 
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        logger.debug("Processing request");
         Map<String, String> jsonData = new FileLoader().loadFile(request);
 
         if(!jsonData.containsKey("file") || !jsonData.containsKey("jsonFileFormat")) {
             request.setAttribute("errorMessage", "<strong>Invalid request!</strong><br/>");
+            logger.debug("Invalid request");
             doGet(request, response);
 
         } else if (Strings.isNullOrEmpty(jsonData.get("file"))) {
             request.setAttribute("errorMessage", "<strong>Unsupported file</strong><br/>");
+            logger.debug("Empty diagram json");
             doGet(request, response);
         } else {
             request.getSession().setAttribute("json_graph", jsonData.get("file"));
             request.getSession().setAttribute("json_graph_type", jsonData.get("jsonFileFormat"));
             request.getSession().setAttribute("graph_filename", jsonData.get("filename"));
             response.sendRedirect(getServletContext().getInitParameter("APP_HOME_URL") + "graph");
+            logger.debug("send redirect to /graph");
         }
+        logger.debug("Request processed");
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDBDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDBDiagram.java
index dfa477a..a73a748 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDBDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDBDiagram.java
@@ -4,6 +4,8 @@ import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.Diagram;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.json.JSONObject;
 
 import javax.servlet.http.HttpServletRequest;
@@ -15,12 +17,16 @@ import java.io.IOException;
  */
 public class GetDBDiagram extends BaseServlet {
 
+    private static final Logger logger = LogManager.getLogger();
+
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
         String diagramId = request.getParameter("id");
 
         if (Strings.isNullOrEmpty(diagramId)) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            logger.debug("Diagram id is empty");
             return;
         }
 
@@ -29,6 +35,7 @@ public class GetDBDiagram extends BaseServlet {
 
         if (!diagram.isPublic() && (!isLoggedIn(request) || (isLoggedIn(request) && diagram.getUserId() != getUserId(request)))) {
             response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+            logger.debug("User is unauthorized");
             return;
         }
 
@@ -39,5 +46,6 @@ public class GetDBDiagram extends BaseServlet {
         response.setStatus(HttpServletResponse.SC_OK);
         response.getWriter().write(json.toString());
         response.getWriter().flush();
+        logger.debug("Response OK");
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetPrivateDiagrams.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetPrivateDiagrams.java
index 28972ea..41d1e74 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetPrivateDiagrams.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetPrivateDiagrams.java
@@ -3,6 +3,8 @@ package cz.zcu.kiv.offscreen.servlets.api;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.Diagram;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.json.JSONArray;
 import org.json.JSONObject;
 
@@ -14,10 +16,15 @@ import java.util.Map;
 
 public class GetPrivateDiagrams extends BaseServlet {
 
+    private static final Logger logger = LogManager.getLogger();
+
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
+
         if (!isLoggedIn(request)) {
             response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+            logger.debug("User is unauthorized");
             return;
         }
 
@@ -37,5 +44,7 @@ public class GetPrivateDiagrams extends BaseServlet {
         response.setStatus(HttpServletResponse.SC_OK);
         response.getWriter().write(json.toString());
         response.getWriter().flush();
+        logger.debug("Response OK");
+
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
index 36e8a75..16c90a8 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetSessionDiagram.java
@@ -8,6 +8,8 @@ import cz.zcu.kiv.offscreen.graph.loader.GraphJSONDataLoader;
 import cz.zcu.kiv.offscreen.graph.loader.JSONConfigLoader;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import net.sf.json.JSONObject;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -17,6 +19,7 @@ import java.io.IOException;
  * This class is used for loading diagrams from session.
  */
 public class GetSessionDiagram extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     /**
      * Constructs graph data using either the current graph version or the version set in query parameter. Resulting
@@ -24,6 +27,8 @@ public class GetSessionDiagram extends BaseServlet {
      */
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
+
         response.setContentType("application/json");
         response.setCharacterEncoding("UTF-8");
 
@@ -44,9 +49,11 @@ public class GetSessionDiagram extends BaseServlet {
 
             switch (jsonType) {
                 case "spade":
+                    logger.debug("Processing Spade json");
                     rawJson = convertSpadeToRawJson(jsonToDisplay);
                     break;
                 default:
+                    logger.debug("Processing Raw json");
                     rawJson = jsonToDisplay;
             }
 
@@ -57,10 +64,12 @@ public class GetSessionDiagram extends BaseServlet {
             response.setStatus(HttpServletResponse.SC_OK);
             response.getWriter().write(jsonObject.toString());
             response.getWriter().flush();
+            logger.debug("Response OK");
             return;
         }
 
         response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+        logger.debug("Response BAD REQUEST");
     }
 
     /**
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Login.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Login.java
index 7131f3b..d45de8b 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Login.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Login.java
@@ -5,6 +5,8 @@ import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.User;
 import cz.zcu.kiv.offscreen.vo.UserVO;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.json.JSONObject;
 
 import javax.servlet.http.HttpServletRequest;
@@ -14,9 +16,11 @@ import java.util.HashMap;
 import java.util.Map;
 
 public class Login extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
         String username = request.getParameter("username");
         String password = request.getParameter("password");
 
@@ -24,10 +28,12 @@ public class Login extends BaseServlet {
 
         if (Strings.isNullOrEmpty(username)) {
             errors.put("username", "Please enter username.");
+            logger.debug("Empty user name");
         }
 
         if (Strings.isNullOrEmpty(password)) {
             errors.put("password", "Please enter password.");
+            logger.debug("Empty password");
         }
 
         if (errors.isEmpty()) {
@@ -54,6 +60,7 @@ public class Login extends BaseServlet {
                 response.setStatus(HttpServletResponse.SC_ACCEPTED);
                 response.getWriter().write(json.toString());
                 response.getWriter().flush();
+                logger.debug("Response ACCEPTED");
 
             } else {
                 request.getSession().setAttribute("isLoggedIn", false);
@@ -61,6 +68,7 @@ public class Login extends BaseServlet {
                 request.getSession().setAttribute("user", null);
 
                 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+                logger.debug("Response UNAUTHORIZED");
             }
 
         } else {
@@ -71,6 +79,7 @@ public class Login extends BaseServlet {
             response.setContentType("application/json");
             response.getWriter().write(json.toString());
             response.getWriter().flush();
+            logger.debug("Response BAD REQUEST");
         }
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Logout.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Logout.java
index 98d0318..1e1720b 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Logout.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Logout.java
@@ -1,18 +1,23 @@
 package cz.zcu.kiv.offscreen.servlets.api;
 
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 public class Logout extends BaseServlet {
-	
+    private static final Logger logger = LogManager.getLogger();
+
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+        logger.debug("Processing request");
         request.getSession().setAttribute("isLoggedIn", false);
         request.getSession().setAttribute("userId", null);
         request.getSession().setAttribute("user", null);
 
         response.setStatus(HttpServletResponse.SC_RESET_CONTENT);
+        logger.debug("Response RESET CONTENT");
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Register.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Register.java
index 1e0bdaa..44adc66 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Register.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/Register.java
@@ -4,6 +4,8 @@ import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.User;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.json.JSONObject;
 
 import javax.servlet.http.HttpServletRequest;
@@ -15,13 +17,14 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class Register extends BaseServlet {
-    
-    private static final String EMAIL_ADDRESS_PATTERN = "^[A-Za-z0-9-\\+_]+(\\.[A-Za-z0-9-_]+)*@" +
+	private static final Logger logger = LogManager.getLogger();
+	private static final String EMAIL_ADDRESS_PATTERN = "^[A-Za-z0-9-\\+_]+(\\.[A-Za-z0-9-_]+)*@" +
     											"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*" +
     											"(\\.[A-Za-z]{2,})$";
     
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+		logger.debug("Processing request");
 		String name = request.getParameter("name");
 		String email = request.getParameter("email");
 		String username = request.getParameter("username");
@@ -35,29 +38,43 @@ public class Register extends BaseServlet {
 
 		if (Strings.isNullOrEmpty(name)) {
 			errors.put("name", "Please enter name.");
+			logger.debug("Empty name");
 		}
 
 		if (Strings.isNullOrEmpty(email)) {
 			errors.put("email", "Please enter e-mail address.");
+			logger.debug("Empty e-mail address");
+
 		} else if (!isEmailAddressValid(email)) {
 			errors.put("email", "Please enter valid e-mail address.");
+			logger.debug("Invalid e-mail address");
+
 		} else if (user.isEmailExists(email)) {
 			errors.put("email", "E-mail already exists.");
+			logger.debug("E-mail exists");
 		}
 
 		if (Strings.isNullOrEmpty(username)) {
 			errors.put("username", "Please enter username.");
+			logger.debug("Empty user name");
+
 		} else if (user.isNickExists(username)) {
 			errors.put("username", "Nickname already exists.");
+			logger.debug("Username(nickname) exists");
 		}
     	
     	if (Strings.isNullOrEmpty(password) || Strings.isNullOrEmpty(passwordCheck)) {
     		errors.put("password", "Please enter password.");
-    	} else if (password.length() < 5) {
+			logger.debug("Empty password");
+
+		} else if (password.length() < 5) {
     		errors.put("password", "Passwords must be at least 5 characters long.");
+			logger.debug("Invalid password");
+
 		} else if (!password.equals(passwordCheck)) {
 			errors.put("passwordCheck", "Passwords must be equal.");
-    	}
+			logger.debug("Passwords not match");
+		}
 
     	if (errors.isEmpty()) {
     		Map<String, String> userMap = new HashMap<>();
@@ -70,8 +87,9 @@ public class Register extends BaseServlet {
     		user.register(userMap);
 
 			response.setStatus(HttpServletResponse.SC_CREATED);
+			logger.debug("User created");
 
-    	} else {
+		} else {
 			JSONObject json = new JSONObject();
 			json.put("error", new JSONObject(errors));
 
@@ -79,6 +97,7 @@ public class Register extends BaseServlet {
 			response.setContentType("application/json");
 			response.getWriter().write(json.toString());
 			response.getWriter().flush();
+			logger.debug("Response BAD REQUEST");
 		}
     }
     
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java
index 7084987..8c2b214 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/RemoveDiagram.java
@@ -4,17 +4,22 @@ import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.Diagram;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 public class RemoveDiagram extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
         if (!isLoggedIn(request)) {
             response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+            logger.debug("User is unauthorized");
             return;
         }
 
@@ -24,6 +29,7 @@ public class RemoveDiagram extends BaseServlet {
 
         if (Strings.isNullOrEmpty(diagramId)) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            logger.debug("Empty diagram id");
             return;
         }
 
@@ -32,10 +38,12 @@ public class RemoveDiagram extends BaseServlet {
 
         if (diagram.getUserId() != loggedUserId) {
             response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+            logger.debug("User is not owner of diagram");
             return;
         }
 
         diagram.delete();
+        logger.debug("Diagram removed");
 
         response.setStatus(HttpServletResponse.SC_NO_CONTENT);
     }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
index 5a10f92..a7d99fa 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
@@ -4,6 +4,8 @@ import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
 import cz.zcu.kiv.offscreen.user.DB;
 import cz.zcu.kiv.offscreen.user.Diagram;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.json.JSONObject;
 
 import javax.servlet.http.HttpServletRequest;
@@ -13,11 +15,15 @@ import java.util.HashMap;
 import java.util.Map;
 
 public class SaveDiagram extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        logger.debug("Processing request");
+
         if (!isLoggedIn(request)) {
             response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+            logger.debug("User is unauthorized");
             return;
         }
 
@@ -33,6 +39,7 @@ public class SaveDiagram extends BaseServlet {
         // input parameters are invalid
         if (Strings.isNullOrEmpty(name) || Strings.isNullOrEmpty(graphJson)) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            logger.debug("Input name or json is empty");
             return;
         }
 
@@ -40,16 +47,16 @@ public class SaveDiagram extends BaseServlet {
         Diagram diagram;
 
         if (Strings.isNullOrEmpty(diagramId)) {
-            // new diagram
+            logger.debug("Creating new diagram");
             diagram = new Diagram(db);
 
         } else {
-            // diagram exists
+            logger.debug("Getting existing diagram from database");
             diagram = new Diagram(db, Integer.parseInt(diagramId));
 
-            // user is not owner of the diagram
             if (loggedUserId != diagram.getUserId()) {
                 response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+                logger.debug("User is not owner of diagram");
                 return;
             }
         }
@@ -61,6 +68,7 @@ public class SaveDiagram extends BaseServlet {
         diagramParams.put("user_id", Integer.toString(loggedUserId));
 
         diagram.update(diagramParams);
+        logger.debug("Diagram created or updated.");
 
         // send response
         JSONObject json = new JSONObject(diagram.getDiagram());
@@ -70,5 +78,6 @@ public class SaveDiagram extends BaseServlet {
         response.setStatus(HttpServletResponse.SC_OK);
         response.getWriter().write(json.toString());
         response.getWriter().flush();
+        logger.debug("Response OK");
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/rest/RawInput.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/rest/RawInput.java
index 1452691..ed0ce7a 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/rest/RawInput.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/rest/RawInput.java
@@ -2,6 +2,8 @@ package cz.zcu.kiv.offscreen.servlets.rest;
 
 import com.google.common.base.Strings;
 import cz.zcu.kiv.offscreen.servlets.BaseServlet;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -12,20 +14,24 @@ import java.io.IOException;
  * @author Tomáš Šimandl
  */
 public class RawInput extends BaseServlet {
+    private static final Logger logger = LogManager.getLogger();
 
     @Override
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        logger.debug("Processing request");
         request.setCharacterEncoding("UTF-8");
         String diagram = request.getParameter("rawDiagram");
         String type = "raw";
 
         if (Strings.isNullOrEmpty(diagram)) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST);
+            logger.debug("Diagram json is empty");
             return;
         }
 
         request.getSession().setAttribute("json_graph", diagram);
         request.getSession().setAttribute("json_graph_type", type);
         response.sendRedirect(getServletContext().getInitParameter("HOME_URL") + "graph");
+        logger.debug("Send redirect to /graph");
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/user/DB.java b/sources/src/main/java/cz/zcu/kiv/offscreen/user/DB.java
index 08af9fa..b61e012 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/user/DB.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/user/DB.java
@@ -28,6 +28,7 @@ public class DB {
 		String password = context.getInitParameter("jdbc.password");
 
 		try {
+			logger.debug("Opening database connection");
 			Class.forName(driverClassName);
 			connection = DriverManager.getConnection(url, username, password);
 			connection.setAutoCommit(true);
