Index: /trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/Main.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/Main.java	(revision 6852)
@@ -282,4 +282,24 @@
 
     /**
+     * Determines if debug log level is enabled.
+     * Useful to avoid costly construction of debug messages when not enabled.
+     * @return {@code true} if log level is at least debug, {@code false} otherwise
+     * @since 6852
+     */
+    public static boolean isDebugEnabled() {
+        return logLevel >= 4;
+    }
+
+    /**
+     * Determines if trace log level is enabled.
+     * Useful to avoid costly construction of trace messages when not enabled.
+     * @return {@code true} if log level is at least trace, {@code false} otherwise
+     * @since 6852
+     */
+    public static boolean isTraceEnabled() {
+        return logLevel >= 5;
+    }
+
+    /**
      * Prints a formatted error message if logging is on. Calls {@link MessageFormat#format}
      * function to format text.
@@ -595,6 +615,8 @@
             final long startTime = System.currentTimeMillis();
             initialize();
-            final long elapsedTime = System.currentTimeMillis() - startTime;
-            Main.debug(tr("{0} completed in {1}", name, Utils.getDurationString(elapsedTime)));
+            if (isDebugEnabled()) {
+                final long elapsedTime = System.currentTimeMillis() - startTime;
+                Main.debug(tr("{0} completed in {1}", name, Utils.getDurationString(elapsedTime)));
+            }
             return null;
         }
@@ -660,5 +682,5 @@
         return getEditLayer().data;
     }
-    
+
     /**
      * Replies the current selected primitives, from a end-user point of view.
@@ -666,5 +688,5 @@
      * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
      * see {@link DrawAction#getInProgressSelection()}.
-     * 
+     *
      * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
      * @since 6546
@@ -1421,5 +1443,5 @@
      * Adds a new network error that occur to give a hint about broken Internet connection.
      * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
-     * 
+     *
      * @param url The accessed URL that caused the error
      * @param t The network error
@@ -1441,5 +1463,5 @@
      * Adds a new network error that occur to give a hint about broken Internet connection.
      * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
-     * 
+     *
      * @param url The accessed URL that caused the error
      * @param t The network error
Index: /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java	(revision 6852)
@@ -308,6 +308,8 @@
             initializeTests(getTests());
             testsInitialized = true;
-            final long elapsedTime = System.currentTimeMillis() - startTime;
-            Main.debug("Initializing validator tests completed in " + Utils.getDurationString(elapsedTime));
+            if (Main.isDebugEnabled()) {
+                final long elapsedTime = System.currentTimeMillis() - startTime;
+                Main.debug("Initializing validator tests completed in " + Utils.getDurationString(elapsedTime));
+            }
         }
     }
Index: /trunk/src/org/openstreetmap/josm/gui/MapStatus.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 6852)
@@ -259,6 +259,6 @@
                             wait(1000);
                         } catch (InterruptedException e) {
-                            // Occurs frequently during JOSM shutdown, log set to debug only
-                            Main.debug("InterruptedException in "+MapStatus.class.getSimpleName());
+                            // Occurs frequently during JOSM shutdown, log set to trace only
+                            Main.trace("InterruptedException in "+MapStatus.class.getSimpleName());
                         }
                         ms.modifiers = mouseState.modifiers;
Index: /trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 6852)
@@ -687,8 +687,12 @@
                     errorHeader = activeConnection.getHeaderField("Error");
                     Main.error("Error header: " + errorHeader);
-                } else if (retCode != 200 && responseBody.length()>0) {
+                } else if (retCode != HttpURLConnection.HTTP_OK && responseBody.length()>0) {
                     Main.error("Error body: " + responseBody);
                 }
                 activeConnection.disconnect();
+
+                if (Main.isDebugEnabled()) {
+                    Main.debug("RESPONSE: "+ activeConnection.getHeaderFields());
+                }
 
                 errorHeader = errorHeader == null? null : errorHeader.trim();
@@ -723,7 +727,7 @@
                 }
                 throw new OsmTransferException(e);
-            } catch(IOException e){
+            } catch(IOException e) {
                 throw new OsmTransferException(e);
-            } catch(OsmTransferCanceledException e){
+            } catch(OsmTransferCanceledException e) {
                 throw e;
             } catch(OsmTransferException e) {
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 6852)
@@ -158,5 +158,7 @@
             }
             try {
-                Main.debug(activeConnection.getHeaderFields().toString());
+                if (Main.isDebugEnabled()) {
+                    Main.debug("RESPONSE: "+activeConnection.getHeaderFields());
+                }
                 if (activeConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
                     throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED,null,null);
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6851)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6852)
@@ -749,4 +749,11 @@
             connection.setRequestProperty("Connection", "close");
         }
+        if (Main.isDebugEnabled()) {
+            try {
+                Main.debug("REQUEST: "+ connection.getRequestProperties());
+            } catch (IllegalStateException e) {
+                Main.warn(e);
+            }
+        }
         return connection;
     }
