Blame SOURCES/loglevel.patch

40e342
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
40e342
index 1664dfce..8ce364a3 100644
40e342
--- a/include/libssh/libssh.h
40e342
+++ b/include/libssh/libssh.h
40e342
@@ -322,7 +322,7 @@ enum {
40e342
 	/** No logging at all
40e342
 	 */
40e342
 	SSH_LOG_NOLOG=0,
40e342
-	/** Only warnings
40e342
+	/** Only fatal warnings
40e342
 	 */
40e342
 	SSH_LOG_WARNING,
40e342
 	/** High level protocol information
40e342
@@ -347,7 +347,7 @@ enum {
40e342
 
40e342
 /** No logging at all */
40e342
 #define SSH_LOG_NONE 0
40e342
-/** Show only warnings */
40e342
+/** Show only fatal warnings */
40e342
 #define SSH_LOG_WARN 1
40e342
 /** Get some information what's going on */
40e342
 #define SSH_LOG_INFO 2
40e342
diff --git a/src/agent.c b/src/agent.c
40e342
index 62b0093e..02f628cd 100644
40e342
--- a/src/agent.c
40e342
+++ b/src/agent.c
40e342
@@ -261,12 +261,12 @@ static int agent_talk(struct ssh_session_struct *session,
40e342
   if (atomicio(session->agent, payload, 4, 0) == 4) {
40e342
     if (atomicio(session->agent, ssh_buffer_get(request), len, 0)
40e342
         != len) {
40e342
-      SSH_LOG(SSH_LOG_WARN, "atomicio sending request failed: %s",
40e342
+      SSH_LOG(SSH_LOG_TRACE, "atomicio sending request failed: %s",
40e342
           strerror(errno));
40e342
       return -1;
40e342
     }
40e342
   } else {
40e342
-    SSH_LOG(SSH_LOG_WARN,
40e342
+    SSH_LOG(SSH_LOG_TRACE,
40e342
         "atomicio sending request length failed: %s",
40e342
         strerror(errno));
40e342
     return -1;
40e342
@@ -274,7 +274,7 @@ static int agent_talk(struct ssh_session_struct *session,
40e342
 
40e342
   /* wait for response, read the length of the response packet */
40e342
   if (atomicio(session->agent, payload, 4, 1) != 4) {
40e342
-    SSH_LOG(SSH_LOG_WARN, "atomicio read response length failed: %s",
40e342
+    SSH_LOG(SSH_LOG_TRACE, "atomicio read response length failed: %s",
40e342
         strerror(errno));
40e342
     return -1;
40e342
   }
40e342
@@ -293,12 +293,12 @@ static int agent_talk(struct ssh_session_struct *session,
40e342
       n = sizeof(payload);
40e342
     }
40e342
     if (atomicio(session->agent, payload, n, 1) != n) {
40e342
-      SSH_LOG(SSH_LOG_WARN,
40e342
+      SSH_LOG(SSH_LOG_DEBUG,
40e342
           "Error reading response from authentication socket.");
40e342
       return -1;
40e342
     }
40e342
     if (ssh_buffer_add_data(reply, payload, n) < 0) {
40e342
-      SSH_LOG(SSH_LOG_WARN, "Not enough space");
40e342
+      SSH_LOG(SSH_LOG_DEBUG, "Not enough space");
40e342
       return -1;
40e342
     }
40e342
     len -= n;
40e342
@@ -353,7 +353,7 @@ uint32_t ssh_agent_get_ident_count(struct ssh_session_struct *session)
40e342
     type = bswap_32(type);
40e342
 #endif
40e342
 
40e342
-    SSH_LOG(SSH_LOG_WARN,
40e342
+    SSH_LOG(SSH_LOG_TRACE,
40e342
             "Answer type: %d, expected answer: %d",
40e342
             type, SSH2_AGENT_IDENTITIES_ANSWER);
40e342
 
40e342
@@ -573,7 +573,7 @@ ssh_string ssh_agent_sign_data(ssh_session session,
40e342
 #endif
40e342
 
40e342
     if (agent_failed(type)) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Agent reports failure in signing the key");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Agent reports failure in signing the key");
40e342
         SSH_BUFFER_FREE(reply);
40e342
         return NULL;
40e342
     } else if (type != SSH2_AGENT_SIGN_RESPONSE) {
40e342
diff --git a/src/auth.c b/src/auth.c
40e342
index 3a5f0efb..59d7e8dd 100644
40e342
--- a/src/auth.c
40e342
+++ b/src/auth.c
40e342
@@ -71,7 +71,7 @@ static int ssh_userauth_request_service(ssh_session session) {
40e342
 
40e342
     rc = ssh_service_request(session, "ssh-userauth");
40e342
     if ((rc != SSH_OK) && (rc != SSH_AGAIN)) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Failed to request \"ssh-userauth\" service");
40e342
     }
40e342
 
40e342
@@ -199,7 +199,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_banner) {
40e342
 
40e342
     banner = ssh_buffer_get_ssh_string(packet);
40e342
     if (banner == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Invalid SSH_USERAUTH_BANNER packet");
40e342
     } else {
40e342
         SSH_LOG(SSH_LOG_DEBUG,
40e342
@@ -237,7 +237,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_failure) {
40e342
 
40e342
     if (partial) {
40e342
         session->auth.state = SSH_AUTH_STATE_PARTIAL;
40e342
-        SSH_LOG(SSH_LOG_INFO,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "Partial success for '%s'. Authentication that can continue: %s",
40e342
                 current_method,
40e342
                 auth_methods);
40e342
@@ -247,7 +247,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_failure) {
40e342
                       "Access denied for '%s'. Authentication that can continue: %s",
40e342
                       current_method,
40e342
                       auth_methods);
40e342
-        SSH_LOG(SSH_LOG_INFO,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "%s",
40e342
                 ssh_get_error(session));
40e342
 
40e342
@@ -942,7 +942,7 @@ int ssh_userauth_agent(ssh_session session,
40e342
                 session->agent_state = NULL;
40e342
                 return rc;
40e342
             } else if (rc != SSH_AUTH_SUCCESS) {
40e342
-                SSH_LOG(SSH_LOG_INFO,
40e342
+                SSH_LOG(SSH_LOG_DEBUG,
40e342
                         "Server accepted public key but refused the signature");
40e342
                 ssh_key_free(state->pubkey);
40e342
                 state->pubkey = ssh_agent_get_next_ident(session, &state->comment);
40e342
@@ -1102,7 +1102,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
40e342
 
40e342
                 rc = ssh_pki_export_pubkey_file(state->pubkey, pubkey_file);
40e342
                 if (rc == SSH_ERROR) {
40e342
-                    SSH_LOG(SSH_LOG_WARN,
40e342
+                    SSH_LOG(SSH_LOG_TRACE,
40e342
                             "Could not write public key to file: %s",
40e342
                             pubkey_file);
40e342
                 }
40e342
@@ -1112,7 +1112,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
40e342
         if (state->state == SSH_AUTH_AUTO_STATE_KEY_IMPORTED) {
40e342
             rc = ssh_userauth_try_publickey(session, username, state->pubkey);
40e342
             if (rc == SSH_AUTH_ERROR) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "Public key authentication error for %s",
40e342
                         privkey_file);
40e342
                 ssh_key_free(state->privkey);
40e342
@@ -1159,7 +1159,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
40e342
                     /* If the file doesn't exist, continue */
40e342
                     ssh_key_free(state->pubkey);
40e342
                     state->pubkey = NULL;
40e342
-                    SSH_LOG(SSH_LOG_INFO,
40e342
+                    SSH_LOG(SSH_LOG_DEBUG,
40e342
                             "Private key %s doesn't exist.",
40e342
                             privkey_file);
40e342
                     state->it = state->it->next;
40e342
@@ -1174,7 +1174,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
40e342
                 ssh_key_free(state->pubkey);
40e342
                 SAFE_FREE(session->auth.auto_state);
40e342
                 if (rc == SSH_AUTH_SUCCESS) {
40e342
-                    SSH_LOG(SSH_LOG_INFO,
40e342
+                    SSH_LOG(SSH_LOG_DEBUG,
40e342
                             "Successfully authenticated using %s",
40e342
                             privkey_file);
40e342
                 }
40e342
@@ -1187,15 +1187,15 @@ int ssh_userauth_publickey_auto(ssh_session session,
40e342
             ssh_key_free(state->privkey);
40e342
             ssh_key_free(state->pubkey);
40e342
 
40e342
-            SSH_LOG(SSH_LOG_WARN,
40e342
+            SSH_LOG(SSH_LOG_DEBUG,
40e342
                     "The server accepted the public key but refused the signature");
40e342
             state->it = state->it->next;
40e342
             state->state = SSH_AUTH_AUTO_STATE_PUBKEY;
40e342
             /* continue */
40e342
         }
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_INFO,
40e342
-            "Tried every public key, none matched");
40e342
+    SSH_LOG(SSH_LOG_WARN,
40e342
+            "Access denied: Tried every public key, none matched");
40e342
     SAFE_FREE(session->auth.auto_state);
40e342
     return SSH_AUTH_DENIED;
40e342
 }
40e342
@@ -1917,7 +1917,7 @@ int ssh_userauth_gssapi(ssh_session session) {
40e342
     } else if (rc == SSH_ERROR) {
40e342
         return SSH_AUTH_ERROR;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Authenticating with gssapi-with-mic");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Authenticating with gssapi-with-mic");
40e342
 
40e342
     session->auth.current_method = SSH_AUTH_METHOD_GSSAPI_MIC;
40e342
     session->auth.state = SSH_AUTH_STATE_NONE;
40e342
diff --git a/src/bind.c b/src/bind.c
40e342
index fa8df9ea..d65a789e 100644
40e342
--- a/src/bind.c
40e342
+++ b/src/bind.c
40e342
@@ -294,7 +294,7 @@ int ssh_bind_listen(ssh_bind sshbind) {
40e342
 
40e342
       sshbind->bindfd = fd;
40e342
   } else {
40e342
-      SSH_LOG(SSH_LOG_INFO, "Using app-provided bind socket");
40e342
+      SSH_LOG(SSH_LOG_DEBUG, "Using app-provided bind socket");
40e342
   }
40e342
   return 0;
40e342
 }
40e342
diff --git a/src/bind_config.c b/src/bind_config.c
40e342
index 14b84db0..56b66660 100644
40e342
--- a/src/bind_config.c
40e342
+++ b/src/bind_config.c
40e342
@@ -343,7 +343,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HOSTKEY, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set Hostkey value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -354,7 +354,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDADDR, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set ListenAddress value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -365,7 +365,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_BINDPORT_STR, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set Port value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -376,7 +376,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_C_S, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set C->S Ciphers value '%s'",
40e342
                         count, p);
40e342
                 break;
40e342
@@ -384,7 +384,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
 
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_CIPHERS_S_C, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set S->C Ciphers value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -395,7 +395,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_C_S, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set C->S MAC value '%s'",
40e342
                         count, p);
40e342
                 break;
40e342
@@ -403,7 +403,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
 
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_HMAC_S_C, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set S->C MAC value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -417,10 +417,10 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
             if (strcasecmp(p, "quiet") == 0) {
40e342
                 value = SSH_LOG_NONE;
40e342
             } else if (strcasecmp(p, "fatal") == 0 ||
40e342
-                    strcasecmp(p, "error")== 0 ||
40e342
-                    strcasecmp(p, "info") == 0) {
40e342
+                    strcasecmp(p, "error")== 0) {
40e342
                 value = SSH_LOG_WARN;
40e342
-            } else if (strcasecmp(p, "verbose") == 0) {
40e342
+            } else if (strcasecmp(p, "verbose") == 0 ||
40e342
+                    strcasecmp(p, "info") == 0) {
40e342
                 value = SSH_LOG_INFO;
40e342
             } else if (strcasecmp(p, "DEBUG") == 0 ||
40e342
                     strcasecmp(p, "DEBUG1") == 0) {
40e342
@@ -433,7 +433,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
                 rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_LOG_VERBOSITY,
40e342
                         &value);
40e342
                 if (rc != 0) {
40e342
-                    SSH_LOG(SSH_LOG_WARN,
40e342
+                    SSH_LOG(SSH_LOG_TRACE,
40e342
                             "line %d: Failed to set LogLevel value '%s'",
40e342
                             count, p);
40e342
                 }
40e342
@@ -445,7 +445,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
         if (p && (*parser_flags & PARSING)) {
40e342
             rc = ssh_bind_options_set(bind, SSH_BIND_OPTIONS_KEY_EXCHANGE, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set KexAlgorithms value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -520,13 +520,13 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
                 /* Skip one argument */
40e342
                 p = ssh_config_get_str_tok(&s, NULL);
40e342
                 if (p == NULL || p[0] == '\0') {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "line %d: Match keyword "
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
40e342
                             "'%s' requires argument\n", count, p2);
40e342
                     SAFE_FREE(x);
40e342
                     return -1;
40e342
                 }
40e342
                 args++;
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_DEBUG,
40e342
                         "line %d: Unsupported Match keyword '%s', ignoring\n",
40e342
                         count,
40e342
                         p2);
40e342
@@ -556,7 +556,7 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
             rc = ssh_bind_options_set(bind,
40e342
                                  SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set PubKeyAcceptedKeyTypes value '%s'",
40e342
                         count, p);
40e342
             }
40e342
@@ -568,26 +568,26 @@ ssh_bind_config_parse_line(ssh_bind bind,
40e342
             rc = ssh_bind_options_set(bind,
40e342
                                  SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS, p);
40e342
             if (rc != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Failed to set HostkeyAlgorithms value '%s'",
40e342
                         count, p);
40e342
             }
40e342
         }
40e342
         break;
40e342
     case BIND_CFG_NOT_ALLOWED_IN_MATCH:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Option not allowed in Match block: %s, line: %d",
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Option not allowed in Match block: %s, line: %d",
40e342
                 keyword, count);
40e342
         break;
40e342
     case BIND_CFG_UNKNOWN:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown option: %s, line: %d",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown option: %s, line: %d",
40e342
                 keyword, count);
40e342
         break;
40e342
     case BIND_CFG_UNSUPPORTED:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported option: %s, line: %d",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported option: %s, line: %d",
40e342
                 keyword, count);
40e342
         break;
40e342
     case BIND_CFG_NA:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Option not applicable: %s, line: %d",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Option not applicable: %s, line: %d",
40e342
                 keyword, count);
40e342
         break;
40e342
     default:
40e342
diff --git a/src/buffer.c b/src/buffer.c
40e342
index ce12f491..685fd455 100644
40e342
--- a/src/buffer.c
40e342
+++ b/src/buffer.c
40e342
@@ -878,7 +878,7 @@ static int ssh_buffer_pack_allocate_va(struct ssh_buffer_struct *buffer,
40e342
             cstring = NULL;
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid buffer format %c", *p);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
40e342
             rc = SSH_ERROR;
40e342
         }
40e342
         if (rc != SSH_OK){
40e342
@@ -1007,7 +1007,7 @@ int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
40e342
             cstring = NULL;
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid buffer format %c", *p);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
40e342
             rc = SSH_ERROR;
40e342
         }
40e342
         if (rc != SSH_OK){
40e342
@@ -1238,7 +1238,7 @@ int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer,
40e342
             rc = SSH_OK;
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid buffer format %c", *p);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
40e342
         }
40e342
         if (rc != SSH_OK) {
40e342
             break;
40e342
diff --git a/src/channels.c b/src/channels.c
40e342
index 1041dbff..36e19598 100644
40e342
--- a/src/channels.c
40e342
+++ b/src/channels.c
40e342
@@ -187,7 +187,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){
40e342
   if (rc != SSH_OK)
40e342
       goto error;
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+  SSH_LOG(SSH_LOG_DEBUG,
40e342
       "Received a CHANNEL_OPEN_CONFIRMATION for channel %d:%d",
40e342
       channel->local_channel,
40e342
       channel->remote_channel);
40e342
@@ -200,7 +200,7 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf){
40e342
       goto error;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+  SSH_LOG(SSH_LOG_DEBUG,
40e342
       "Remote window : %"PRIu32", maxpacket : %"PRIu32,
40e342
       (uint32_t) channel->remote_window,
40e342
       (uint32_t) channel->remote_maxpacket);
40e342
@@ -264,11 +264,14 @@ error:
40e342
 
40e342
 static int ssh_channel_open_termination(void *c){
40e342
   ssh_channel channel = (ssh_channel) c;
40e342
-  if (channel->state != SSH_CHANNEL_STATE_OPENING ||
40e342
-      channel->session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+  if (channel->state != SSH_CHANNEL_STATE_OPENING) {
40e342
     return 1;
40e342
-  else
40e342
+  } else if (channel->session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(channel->session));
40e342
+    return 1;
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 /**
40e342
@@ -320,7 +323,7 @@ channel_open(ssh_channel channel,
40e342
     channel->local_maxpacket = maxpacket;
40e342
     channel->local_window = window;
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Creating a channel %d with %d window and %d max packet",
40e342
             channel->local_channel, window, maxpacket);
40e342
 
40e342
@@ -410,7 +413,7 @@ static int grow_window(ssh_session session,
40e342
   int rc;
40e342
 
40e342
   if(new_window <= channel->local_window){
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
         "growing window (channel %d:%d) to %d bytes : not needed (%d bytes)",
40e342
         channel->local_channel, channel->remote_channel, new_window,
40e342
         channel->local_window);
40e342
@@ -434,7 +437,7 @@ static int grow_window(ssh_session session,
40e342
     goto error;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+  SSH_LOG(SSH_LOG_DEBUG,
40e342
       "growing window (channel %d:%d) to %d bytes",
40e342
       channel->local_channel,
40e342
       channel->remote_channel,
40e342
@@ -504,7 +507,7 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
40e342
     return SSH_PACKET_USED;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+  SSH_LOG(SSH_LOG_DEBUG,
40e342
       "Adding %d bytes to channel (%d:%d) (from %d bytes)",
40e342
       bytes,
40e342
       channel->local_channel,
40e342
@@ -808,7 +811,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
40e342
 	}
40e342
 	if(strcmp(request,"keepalive@openssh.com")==0){
40e342
 	  SAFE_FREE(request);
40e342
-	  SSH_LOG(SSH_LOG_PROTOCOL,"Responding to Openssh's keepalive");
40e342
+	  SSH_LOG(SSH_LOG_DEBUG,"Responding to Openssh's keepalive");
40e342
 
40e342
       rc = ssh_buffer_pack(session->out_buffer,
40e342
                            "bd",
40e342
@@ -824,7 +827,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
40e342
 
40e342
   if (strcmp(request, "auth-agent-req@openssh.com") == 0) {
40e342
     SAFE_FREE(request);
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Received an auth-agent-req request");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Received an auth-agent-req request");
40e342
     ssh_callbacks_execute_list(channel->callbacks,
40e342
                                ssh_channel_callbacks,
40e342
                                channel_auth_agent_req_function,
40e342
@@ -840,7 +843,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
40e342
 	 */
40e342
 	ssh_message_handle_channel_request(session,channel,packet,request,status);
40e342
 #else
40e342
-    SSH_LOG(SSH_LOG_WARNING, "Unhandled channel request %s", request);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Unhandled channel request %s", request);
40e342
 #endif
40e342
 	
40e342
 	SAFE_FREE(request);
40e342
@@ -1403,7 +1406,7 @@ static int channel_write_common(ssh_channel channel,
40e342
   }
40e342
 
40e342
   if (len > INT_MAX) {
40e342
-      SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+      SSH_LOG(SSH_LOG_TRACE,
40e342
               "Length (%u) is bigger than INT_MAX", len);
40e342
       return SSH_ERROR;
40e342
   }
40e342
@@ -1440,14 +1443,14 @@ static int channel_write_common(ssh_channel channel,
40e342
   }
40e342
   while (len > 0) {
40e342
     if (channel->remote_window < len) {
40e342
-      SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+      SSH_LOG(SSH_LOG_DEBUG,
40e342
           "Remote window is %d bytes. going to write %d bytes",
40e342
           channel->remote_window,
40e342
           len);
40e342
       /* What happens when the channel window is zero? */
40e342
       if(channel->remote_window == 0) {
40e342
           /* nothing can be written */
40e342
-          SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+          SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "Wait for a growing window message...");
40e342
           rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_DEFAULT,
40e342
               ssh_channel_waitwindow_termination,channel);
40e342
@@ -1698,11 +1701,14 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_failure){
40e342
 
40e342
 static int ssh_channel_request_termination(void *c){
40e342
   ssh_channel channel = (ssh_channel)c;
40e342
-  if(channel->request_state != SSH_CHANNEL_REQ_STATE_PENDING ||
40e342
-      channel->session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+  if(channel->request_state != SSH_CHANNEL_REQ_STATE_PENDING) {
40e342
     return 1;
40e342
-  else
40e342
+  } else if (channel->session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(channel->session));
40e342
+    return 1;
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 static int channel_request(ssh_channel channel, const char *request,
40e342
@@ -1767,7 +1773,7 @@ pending:
40e342
       rc=SSH_ERROR;
40e342
       break;
40e342
     case SSH_CHANNEL_REQ_STATE_ACCEPTED:
40e342
-      SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+      SSH_LOG(SSH_LOG_DEBUG,
40e342
           "Channel request %s success",request);
40e342
       rc=SSH_OK;
40e342
       break;
40e342
@@ -2237,11 +2243,14 @@ SSH_PACKET_CALLBACK(ssh_request_denied){
40e342
 
40e342
 static int ssh_global_request_termination(void *s){
40e342
   ssh_session session = (ssh_session) s;
40e342
-  if (session->global_req_state != SSH_CHANNEL_REQ_STATE_PENDING ||
40e342
-      session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+  if (session->global_req_state != SSH_CHANNEL_REQ_STATE_PENDING) {
40e342
     return 1;
40e342
-  else
40e342
+  } else if (session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(session));
40e342
+    return 1;
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 /**
40e342
@@ -2324,7 +2333,7 @@ pending:
40e342
   }
40e342
   switch(session->global_req_state){
40e342
     case SSH_CHANNEL_REQ_STATE_ACCEPTED:
40e342
-      SSH_LOG(SSH_LOG_PROTOCOL, "Global request %s success",request);
40e342
+      SSH_LOG(SSH_LOG_DEBUG, "Global request %s success",request);
40e342
       rc=SSH_OK;
40e342
       break;
40e342
     case SSH_CHANNEL_REQ_STATE_DENIED:
40e342
@@ -2808,11 +2817,14 @@ struct ssh_channel_read_termination_struct {
40e342
 static int ssh_channel_read_termination(void *s){
40e342
   struct ssh_channel_read_termination_struct *ctx = s;
40e342
   if (ssh_buffer_get_len(ctx->buffer) >= ctx->count ||
40e342
-      ctx->channel->remote_eof ||
40e342
-      ctx->channel->session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+      ctx->channel->remote_eof) {
40e342
     return 1;
40e342
-  else
40e342
+  } else if (ctx->channel->session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(ctx->channel->session));
40e342
+    return 1;
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 /* TODO FIXME Fix the delayed close thing */
40e342
@@ -3172,10 +3184,12 @@ static int ssh_channel_exit_status_termination(void *c){
40e342
       /* When a channel is closed, no exit status message can
40e342
        * come anymore */
40e342
       (channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) ||
40e342
-      channel->session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+      channel->session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(channel->session));
40e342
     return 1;
40e342
-  else
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 /**
40e342
diff --git a/src/client.c b/src/client.c
40e342
index a4a7317e..82a436fc 100644
40e342
--- a/src/client.c
40e342
+++ b/src/client.c
40e342
@@ -72,7 +72,7 @@ static void socket_callback_connected(int code, int errno_code, void *user){
40e342
 		return;
40e342
 	}
40e342
 
40e342
-	SSH_LOG(SSH_LOG_RARE,"Socket connection callback: %d (%d)",code, errno_code);
40e342
+	SSH_LOG(SSH_LOG_TRACE,"Socket connection callback: %d (%d)",code, errno_code);
40e342
 	if(code == SSH_SOCKET_CONNECTED_OK)
40e342
 		session->session_state=SSH_SESSION_STATE_SOCKET_CONNECTED;
40e342
 	else {
40e342
@@ -400,7 +400,7 @@ static void ssh_client_connection_callback(ssh_session session)
40e342
                 goto error;
40e342
             }
40e342
             set_status(session, 0.4f);
40e342
-            SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+            SSH_LOG(SSH_LOG_DEBUG,
40e342
                     "SSH server banner: %s", session->serverbanner);
40e342
 
40e342
             /* Here we analyze the different protocols the server allows. */
40e342
@@ -475,7 +475,7 @@ error:
40e342
     ssh_socket_close(session->socket);
40e342
     session->alive = 0;
40e342
     session->session_state=SSH_SESSION_STATE_ERROR;
40e342
-
40e342
+    SSH_LOG(SSH_LOG_WARN, "%s", ssh_get_error(session));
40e342
 }
40e342
 
40e342
 /** @internal
40e342
@@ -558,7 +558,7 @@ int ssh_connect(ssh_session session)
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "libssh %s, using threading %s",
40e342
             ssh_copyright(),
40e342
             ssh_threads_get_type());
40e342
@@ -593,7 +593,7 @@ int ssh_connect(ssh_session session)
40e342
     set_status(session, 0.2f);
40e342
 
40e342
     session->alive = 1;
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Socket connecting, now waiting for the callbacks to work");
40e342
 
40e342
 pending:
40e342
diff --git a/src/config.c b/src/config.c
40e342
index 54ada276..5a5058c1 100644
40e342
--- a/src/config.c
40e342
+++ b/src/config.c
40e342
@@ -360,7 +360,7 @@ ssh_config_parse_proxy_jump(ssh_session session, const char *s, bool do_parsing)
40e342
                       next ? next : "",
40e342
                       hostname);
40e342
         if (rv < 0 || rv >= (int)sizeof(com)) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Too long ProxyJump configuration line");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Too long ProxyJump configuration line");
40e342
             rv = SSH_ERROR;
40e342
             goto out;
40e342
         }
40e342
@@ -494,7 +494,7 @@ ssh_config_parse_line(ssh_session session,
40e342
 
40e342
             case MATCH_FINAL:
40e342
             case MATCH_CANONICAL:
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_DEBUG,
40e342
                         "line %d: Unsupported Match keyword '%s', skipping",
40e342
                         count,
40e342
                         p);
40e342
@@ -506,13 +506,13 @@ ssh_config_parse_line(ssh_session session,
40e342
                 /* Skip to the end of line as unsupported */
40e342
                 p = ssh_config_get_cmd(&s);
40e342
                 if (p == NULL || p[0] == '\0') {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "line %d: Match keyword "
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
40e342
                             "'%s' requires argument", count, p2);
40e342
                     SAFE_FREE(x);
40e342
                     return -1;
40e342
                 }
40e342
                 args++;
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_DEBUG,
40e342
                         "line %d: Unsupported Match keyword '%s', ignoring",
40e342
                         count,
40e342
                         p2);
40e342
@@ -531,7 +531,7 @@ ssh_config_parse_line(ssh_session session,
40e342
                 }
40e342
                 localuser = ssh_get_local_username();
40e342
                 if (localuser == NULL) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "line %d: Can not get local username "
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "line %d: Can not get local username "
40e342
                             "for conditional matching.", count);
40e342
                     SAFE_FREE(x);
40e342
                     return -1;
40e342
@@ -545,13 +545,13 @@ ssh_config_parse_line(ssh_session session,
40e342
                 /* Skip one argument */
40e342
                 p = ssh_config_get_str_tok(&s, NULL);
40e342
                 if (p == NULL || p[0] == '\0') {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "line %d: Match keyword "
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "line %d: Match keyword "
40e342
                             "'%s' requires argument", count, p2);
40e342
                     SAFE_FREE(x);
40e342
                     return -1;
40e342
                 }
40e342
                 args++;
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "line %d: Unsupported Match keyword '%s', ignoring",
40e342
                         count,
40e342
                         p2);
40e342
@@ -786,10 +786,10 @@ ssh_config_parse_line(ssh_session session,
40e342
             if (strcasecmp(p, "quiet") == 0) {
40e342
                 value = SSH_LOG_NONE;
40e342
             } else if (strcasecmp(p, "fatal") == 0 ||
40e342
-                    strcasecmp(p, "error")== 0 ||
40e342
-                    strcasecmp(p, "info") == 0) {
40e342
+                    strcasecmp(p, "error")== 0) {
40e342
                 value = SSH_LOG_WARN;
40e342
-            } else if (strcasecmp(p, "verbose") == 0) {
40e342
+            } else if (strcasecmp(p, "verbose") == 0 ||
40e342
+                    strcasecmp(p, "info") == 0) {
40e342
                 value = SSH_LOG_INFO;
40e342
             } else if (strcasecmp(p, "DEBUG") == 0 ||
40e342
                     strcasecmp(p, "DEBUG1") == 0) {
40e342
@@ -834,13 +834,13 @@ ssh_config_parse_line(ssh_session session,
40e342
             ll = strtoll(p, &endp, 10);
40e342
             if (p == endp || ll < 0) {
40e342
                 /* No number or negative */
40e342
-                SSH_LOG(SSH_LOG_WARN, "Invalid argument to rekey limit");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Invalid argument to rekey limit");
40e342
                 break;
40e342
             }
40e342
             switch (*endp) {
40e342
             case 'G':
40e342
                 if (ll > LLONG_MAX / 1024) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -848,7 +848,7 @@ ssh_config_parse_line(ssh_session session,
40e342
                 FALL_THROUGH;
40e342
             case 'M':
40e342
                 if (ll > LLONG_MAX / 1024) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -856,7 +856,7 @@ ssh_config_parse_line(ssh_session session,
40e342
                 FALL_THROUGH;
40e342
             case 'K':
40e342
                 if (ll > LLONG_MAX / 1024) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -872,7 +872,7 @@ ssh_config_parse_line(ssh_session session,
40e342
                 break;
40e342
             }
40e342
             if (*endp != ' ' && *endp != '\0') {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "Invalid trailing characters after the rekey limit: %s",
40e342
                         endp);
40e342
                 break;
40e342
@@ -893,14 +893,14 @@ ssh_config_parse_line(ssh_session session,
40e342
             ll = strtoll(p, &endp, 10);
40e342
             if (p == endp || ll < 0) {
40e342
                 /* No number or negative */
40e342
-                SSH_LOG(SSH_LOG_WARN, "Invalid argument to rekey limit");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Invalid argument to rekey limit");
40e342
                 break;
40e342
             }
40e342
             switch (*endp) {
40e342
             case 'w':
40e342
             case 'W':
40e342
                 if (ll > LLONG_MAX / 7) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -909,7 +909,7 @@ ssh_config_parse_line(ssh_session session,
40e342
             case 'd':
40e342
             case 'D':
40e342
                 if (ll > LLONG_MAX / 24) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -918,7 +918,7 @@ ssh_config_parse_line(ssh_session session,
40e342
             case 'h':
40e342
             case 'H':
40e342
                 if (ll > LLONG_MAX / 60) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -927,7 +927,7 @@ ssh_config_parse_line(ssh_session session,
40e342
             case 'm':
40e342
             case 'M':
40e342
                 if (ll > LLONG_MAX / 60) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Possible overflow of rekey limit");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Possible overflow of rekey limit");
40e342
                     ll = -1;
40e342
                     break;
40e342
                 }
40e342
@@ -946,7 +946,7 @@ ssh_config_parse_line(ssh_session session,
40e342
                 break;
40e342
             }
40e342
             if (*endp != '\0') {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Invalid trailing characters after the"
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Invalid trailing characters after the"
40e342
                         " rekey limit: %s", endp);
40e342
                 break;
40e342
             }
40e342
@@ -982,7 +982,7 @@ ssh_config_parse_line(ssh_session session,
40e342
         }
40e342
         break;
40e342
     case SOC_NA:
40e342
-      SSH_LOG(SSH_LOG_INFO, "Unapplicable option: %s, line: %d",
40e342
+      SSH_LOG(SSH_LOG_TRACE, "Unapplicable option: %s, line: %d",
40e342
               keyword, count);
40e342
       break;
40e342
     case SOC_UNSUPPORTED:
40e342
@@ -990,7 +990,7 @@ ssh_config_parse_line(ssh_session session,
40e342
               keyword, count);
40e342
       break;
40e342
     case SOC_UNKNOWN:
40e342
-      SSH_LOG(SSH_LOG_WARN, "Unknown option: %s, line: %d",
40e342
+      SSH_LOG(SSH_LOG_TRACE, "Unknown option: %s, line: %d",
40e342
               keyword, count);
40e342
       break;
40e342
     default:
40e342
diff --git a/src/config_parser.c b/src/config_parser.c
40e342
index ae2aa2c8..3a219d61 100644
40e342
--- a/src/config_parser.c
40e342
+++ b/src/config_parser.c
40e342
@@ -209,7 +209,7 @@ int ssh_config_parse_uri(const char *tok,
40e342
         /* Verify the port is valid positive number */
40e342
         port_n = strtol(endp + 1, &port_end, 10);
40e342
         if (port_n < 1 || *port_end != '\0') {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Failed to parse port number."
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Failed to parse port number."
40e342
                     " The value '%ld' is invalid or there are some"
40e342
                     " trailing characters: '%s'", port_n, port_end);
40e342
             goto error;
40e342
diff --git a/src/curve25519.c b/src/curve25519.c
40e342
index d2517551..d8e0456a 100644
40e342
--- a/src/curve25519.c
40e342
+++ b/src/curve25519.c
40e342
@@ -339,7 +339,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_client_curve25519_reply){
40e342
     goto error;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+  SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
   session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
 
40e342
   return SSH_PACKET_USED;
40e342
@@ -491,7 +491,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_curve25519_init){
40e342
         goto error;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEX_ECDH_REPLY sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEX_ECDH_REPLY sent");
40e342
     rc = ssh_packet_send(session);
40e342
     if (rc == SSH_ERROR) {
40e342
         return SSH_ERROR;
40e342
@@ -508,7 +508,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_curve25519_init){
40e342
     if (rc == SSH_ERROR) {
40e342
         goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
 
40e342
     return SSH_PACKET_USED;
40e342
 error:
40e342
diff --git a/src/dh-gex.c b/src/dh-gex.c
40e342
index 88a97140..ace572dc 100644
40e342
--- a/src/dh-gex.c
40e342
+++ b/src/dh-gex.c
40e342
@@ -112,7 +112,7 @@ SSH_PACKET_CALLBACK(ssh_packet_client_dhgex_group)
40e342
     (void) type;
40e342
     (void) user;
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEX_DH_GEX_GROUP received");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEX_DH_GEX_GROUP received");
40e342
 
40e342
     if (bignum_ctx_invalid(ctx)) {
40e342
         goto error;
40e342
@@ -246,7 +246,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_client_dhgex_reply)
40e342
     bignum server_pubkey = NULL;
40e342
     (void)type;
40e342
     (void)user;
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEX_DH_GEX_REPLY received");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEX_DH_GEX_REPLY received");
40e342
 
40e342
     ssh_packet_remove_callbacks(session, &ssh_dhgex_client_callbacks);
40e342
     rc = ssh_buffer_unpack(packet,
40e342
@@ -290,7 +290,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_client_dhgex_reply)
40e342
     if (rc == SSH_ERROR) {
40e342
         goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
     session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
 
40e342
     return SSH_PACKET_USED;
40e342
@@ -425,7 +425,7 @@ static int ssh_retrieve_dhgroup_file(FILE *moduli,
40e342
             if (rc == EOF) {
40e342
                 break;
40e342
             }
40e342
-            SSH_LOG(SSH_LOG_INFO, "Invalid moduli entry line %zu", line);
40e342
+            SSH_LOG(SSH_LOG_DEBUG, "Invalid moduli entry line %zu", line);
40e342
             do {
40e342
                 firstbyte = getc(moduli);
40e342
             } while(firstbyte != '\n' && firstbyte != EOF);
40e342
@@ -463,13 +463,13 @@ static int ssh_retrieve_dhgroup_file(FILE *moduli,
40e342
         }
40e342
     }
40e342
     if (*best_size != 0) {
40e342
-        SSH_LOG(SSH_LOG_INFO,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "Selected %zu bits modulus out of %zu candidates in %zu lines",
40e342
                 *best_size,
40e342
                 best_nlines - 1,
40e342
                 line);
40e342
     } else {
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "No moduli found for [%u:%u:%u]",
40e342
                 pmin,
40e342
                 pn,
40e342
@@ -510,7 +510,7 @@ static int ssh_retrieve_dhgroup(uint32_t pmin,
40e342
 
40e342
     moduli = fopen(MODULI_FILE, "r");
40e342
     if (moduli == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "Unable to open moduli file: %s",
40e342
                 strerror(errno));
40e342
         return ssh_fallback_group(pmax, p, g);
40e342
@@ -605,7 +605,7 @@ static SSH_PACKET_CALLBACK(ssh_packet_server_dhgex_request)
40e342
         ssh_set_error_invalid(session);
40e342
         goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_INFO, "dh-gex: DHGEX_REQUEST[%u:%u:%u]", pmin, pn, pmax);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "dh-gex: DHGEX_REQUEST[%u:%u:%u]", pmin, pn, pmax);
40e342
 
40e342
     if (pmin > pn || pn > pmax || pn > DH_PMAX || pmax < DH_PMIN) {
40e342
         ssh_set_error(session,
40e342
diff --git a/src/dh.c b/src/dh.c
40e342
index 18b71734..ede4855d 100644
40e342
--- a/src/dh.c
40e342
+++ b/src/dh.c
40e342
@@ -390,7 +390,7 @@ SSH_PACKET_CALLBACK(ssh_packet_client_dh_reply){
40e342
     goto error;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+  SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
   session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
   return SSH_PACKET_USED;
40e342
 error:
40e342
diff --git a/src/ecdh.c b/src/ecdh.c
40e342
index a4c07ccb..b57789d4 100644
40e342
--- a/src/ecdh.c
40e342
+++ b/src/ecdh.c
40e342
@@ -97,7 +97,7 @@ SSH_PACKET_CALLBACK(ssh_packet_client_ecdh_reply){
40e342
     goto error;
40e342
   }
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+  SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
   session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
 
40e342
   return SSH_PACKET_USED;
40e342
diff --git a/src/ecdh_crypto.c b/src/ecdh_crypto.c
40e342
index a1de27fd..d050544f 100644
40e342
--- a/src/ecdh_crypto.c
40e342
+++ b/src/ecdh_crypto.c
40e342
@@ -317,7 +317,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
         goto error;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEXDH_REPLY sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEXDH_REPLY sent");
40e342
     rc = ssh_packet_send(session);
40e342
     if (rc == SSH_ERROR) {
40e342
         goto error;
40e342
@@ -334,7 +334,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
     if (rc == SSH_ERROR){
40e342
         goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
 
40e342
     return SSH_PACKET_USED;
40e342
 error:
40e342
diff --git a/src/ecdh_gcrypt.c b/src/ecdh_gcrypt.c
40e342
index d9c41bf9..ca643467 100644
40e342
--- a/src/ecdh_gcrypt.c
40e342
+++ b/src/ecdh_gcrypt.c
40e342
@@ -366,7 +366,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
         goto out;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEXDH_REPLY sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEXDH_REPLY sent");
40e342
     rc = ssh_packet_send(session);
40e342
     if (rc != SSH_OK) {
40e342
         goto out;
40e342
@@ -381,7 +381,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
 
40e342
     session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
     rc = ssh_packet_send(session);
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
 
40e342
  out:
40e342
     gcry_sexp_release(param);
40e342
diff --git a/src/ecdh_mbedcrypto.c b/src/ecdh_mbedcrypto.c
40e342
index 718f1522..855d4770 100644
40e342
--- a/src/ecdh_mbedcrypto.c
40e342
+++ b/src/ecdh_mbedcrypto.c
40e342
@@ -293,7 +293,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
         goto out;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEXDH_REPLY sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEXDH_REPLY sent");
40e342
     rc = ssh_packet_send(session);
40e342
     if (rc != SSH_OK) {
40e342
         rc = SSH_ERROR;
40e342
@@ -308,7 +308,7 @@ SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init){
40e342
 
40e342
     session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
40e342
     rc = ssh_packet_send(session);
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
40e342
 
40e342
 out:
40e342
     mbedtls_ecp_group_free(&grp;;
40e342
diff --git a/src/error.c b/src/error.c
40e342
index 22180407..5e850adb 100644
40e342
--- a/src/error.c
40e342
+++ b/src/error.c
40e342
@@ -63,8 +63,8 @@ void _ssh_set_error(void *error,
40e342
     va_end(va);
40e342
 
40e342
     err->error.error_code = code;
40e342
-    if (ssh_get_log_level() >= SSH_LOG_WARN) {
40e342
-        ssh_log_function(SSH_LOG_WARN,
40e342
+    if (ssh_get_log_level() == SSH_LOG_TRACE) {
40e342
+        ssh_log_function(SSH_LOG_TRACE,
40e342
                          function,
40e342
                          err->error.error_buffer);
40e342
     }
40e342
diff --git a/src/gssapi.c b/src/gssapi.c
40e342
index 1d0fb6ae..cfa36a95 100644
40e342
--- a/src/gssapi.c
40e342
+++ b/src/gssapi.c
40e342
@@ -218,8 +218,8 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
 
40e342
     maj_stat = gss_indicate_mechs(&min_stat, &supported);
40e342
     if (maj_stat != GSS_S_COMPLETE) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "indicate mecks %d, %d", maj_stat, min_stat);
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "indicate mecks %d, %d", maj_stat, min_stat);
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "indicate mechs",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -240,7 +240,7 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
             continue;
40e342
         }
40e342
         if(len < 2 || oid_s[0] != SSH_OID_TAG || ((size_t)oid_s[1]) != len - 2){
40e342
-            SSH_LOG(SSH_LOG_WARNING,"GSSAPI: received invalid OID");
40e342
+            SSH_LOG(SSH_LOG_TRACE,"GSSAPI: received invalid OID");
40e342
             continue;
40e342
         }
40e342
         oid.elements = &oid_s[2];
40e342
@@ -253,7 +253,7 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
     }
40e342
     gss_release_oid_set(&min_stat, &supported);
40e342
     if (oid_count == 0){
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL,"GSSAPI: no OID match");
40e342
+        SSH_LOG(SSH_LOG_DEBUG,"GSSAPI: no OID match");
40e342
         ssh_auth_reply_default(session, 0);
40e342
         gss_release_oid_set(&min_stat, &both_supported);
40e342
         return SSH_OK;
40e342
@@ -267,8 +267,8 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
     maj_stat = gss_import_name(&min_stat, &name_buf,
40e342
             (gss_OID) GSS_C_NT_HOSTBASED_SERVICE, &server_name);
40e342
     if (maj_stat != GSS_S_COMPLETE) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "importing name %d, %d", maj_stat, min_stat);
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "importing name %d, %d", maj_stat, min_stat);
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "importing name",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -282,8 +282,8 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
     gss_release_oid_set(&min_stat, &both_supported);
40e342
 
40e342
     if (maj_stat != GSS_S_COMPLETE) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "error acquiring credentials %d, %d", maj_stat, min_stat);
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_TRACE, "error acquiring credentials %d, %d", maj_stat, min_stat);
40e342
+        ssh_gssapi_log_error(SSH_LOG_TRACE,
40e342
                              "acquiring creds",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -291,7 +291,7 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "acquiring credentials %d, %d", maj_stat, min_stat);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "acquiring credentials %d, %d", maj_stat, min_stat);
40e342
 
40e342
     /* finding which OID from client we selected */
40e342
     for (i=0 ; i< n_oid ; ++i){
40e342
@@ -302,7 +302,7 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
40e342
             continue;
40e342
         }
40e342
         if(len < 2 || oid_s[0] != SSH_OID_TAG || ((size_t)oid_s[1]) != len - 2){
40e342
-            SSH_LOG(SSH_LOG_WARNING,"GSSAPI: received invalid OID");
40e342
+            SSH_LOG(SSH_LOG_TRACE,"GSSAPI: received invalid OID");
40e342
             continue;
40e342
         }
40e342
         oid.elements = &oid_s[2];
40e342
@@ -332,7 +332,7 @@ static char *ssh_gssapi_name_to_char(gss_name_t name){
40e342
     OM_uint32 maj_stat, min_stat;
40e342
     char *ptr;
40e342
     maj_stat = gss_display_name(&min_stat, name, &buffer, NULL);
40e342
-    ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+    ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                          "converting name",
40e342
                          maj_stat,
40e342
                          min_stat);
40e342
@@ -407,7 +407,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
40e342
     maj_stat = gss_accept_sec_context(&min_stat, &session->gssapi->ctx, session->gssapi->server_creds,
40e342
             &input_token, input_bindings, &client_name, NULL /*mech_oid*/, &output_token, &ret_flags,
40e342
             NULL /*time*/, &session->gssapi->client_creds);
40e342
-    ssh_gssapi_log_error(SSH_LOG_PROTOCOL,
40e342
+    ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                          "accepting token",
40e342
                          maj_stat,
40e342
                          min_stat);
40e342
@@ -417,7 +417,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
40e342
         session->gssapi->canonic_user = ssh_gssapi_name_to_char(client_name);
40e342
     }
40e342
     if (GSS_ERROR(maj_stat)){
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "Gssapi error",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -524,7 +524,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic)
40e342
         mic_token_buf.value = ssh_string_data(mic_token);
40e342
 
40e342
         maj_stat = gss_verify_mic(&min_stat, session->gssapi->ctx, &mic_buf, &mic_token_buf, NULL);
40e342
-        ssh_gssapi_log_error(SSH_LOG_PROTOCOL,
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "verifying MIC",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -739,8 +739,8 @@ int ssh_gssapi_auth_mic(ssh_session session){
40e342
                                (gss_OID)GSS_C_NT_HOSTBASED_SERVICE,
40e342
                                &session->gssapi->client.server_name);
40e342
     if (maj_stat != GSS_S_COMPLETE) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "importing name %d, %d", maj_stat, min_stat);
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "importing name %d, %d", maj_stat, min_stat);
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "importing name",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -754,7 +754,7 @@ int ssh_gssapi_auth_mic(ssh_session session){
40e342
         return SSH_AUTH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Authenticating with gssapi to host %s with user %s",
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Authenticating with gssapi to host %s with user %s",
40e342
             session->opts.host, session->gssapi->user);
40e342
     rc = ssh_gssapi_match(session, &selected);
40e342
     if (rc == SSH_ERROR) {
40e342
@@ -762,7 +762,7 @@ int ssh_gssapi_auth_mic(ssh_session session){
40e342
     }
40e342
 
40e342
     n_oids = selected->count;
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Sending %zu oids", n_oids);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Sending %zu oids", n_oids);
40e342
 
40e342
     oids = calloc(n_oids, sizeof(ssh_string));
40e342
     if (oids == NULL) {
40e342
@@ -875,7 +875,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response){
40e342
                                     0, NULL, &input_token, NULL,
40e342
                                     &output_token, NULL, NULL);
40e342
     if(GSS_ERROR(maj_stat)){
40e342
-        ssh_gssapi_log_error(SSH_LOG_WARNING,
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "Initializing gssapi context",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -923,7 +923,7 @@ static int ssh_gssapi_send_mic(ssh_session session){
40e342
                            &mic_buf, &mic_token_buf);
40e342
     if (GSS_ERROR(maj_stat)){
40e342
         SSH_BUFFER_FREE(mic_buffer);
40e342
-        ssh_gssapi_log_error(SSH_LOG_PROTOCOL,
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "generating MIC",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
@@ -980,13 +980,13 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
40e342
                                     0, NULL, &input_token, NULL,
40e342
                                     &output_token, NULL, NULL);
40e342
 
40e342
-    ssh_gssapi_log_error(SSH_LOG_PROTOCOL,
40e342
+    ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                          "accepting token",
40e342
                          maj_stat,
40e342
                          min_stat);
40e342
     SSH_STRING_FREE(token);
40e342
     if (GSS_ERROR(maj_stat)){
40e342
-        ssh_gssapi_log_error(SSH_LOG_PROTOCOL,
40e342
+        ssh_gssapi_log_error(SSH_LOG_DEBUG,
40e342
                              "Gssapi error",
40e342
                              maj_stat,
40e342
                              min_stat);
40e342
diff --git a/src/kex.c b/src/kex.c
40e342
index 82071c74..9b599657 100644
40e342
--- a/src/kex.c
40e342
+++ b/src/kex.c
40e342
@@ -345,7 +345,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit)
40e342
     (void)user;
40e342
 
40e342
     if (session->session_state == SSH_SESSION_STATE_AUTHENTICATED) {
40e342
-        SSH_LOG(SSH_LOG_INFO, "Initiating key re-exchange");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Initiating key re-exchange");
40e342
     } else if (session->session_state != SSH_SESSION_STATE_INITIAL_KEX) {
40e342
         ssh_set_error(session,SSH_FATAL,"SSH_KEXINIT received in wrong state");
40e342
         goto error;
40e342
@@ -590,7 +590,7 @@ char *ssh_client_select_hostkeys(ssh_session session)
40e342
     /* This removes the certificate types, unsupported for now */
40e342
     wanted_without_certs = ssh_find_all_matching(HOSTKEYS, wanted);
40e342
     if (wanted_without_certs == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "List of allowed host key algorithms is empty or contains only "
40e342
                 "unsupported algorithms");
40e342
         return NULL;
40e342
@@ -643,7 +643,7 @@ char *ssh_client_select_hostkeys(ssh_session session)
40e342
         fips_hostkeys = ssh_keep_fips_algos(SSH_HOSTKEYS, new_hostkeys);
40e342
         SAFE_FREE(new_hostkeys);
40e342
         if (fips_hostkeys == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARNING,
40e342
+            SSH_LOG(SSH_LOG_TRACE,
40e342
                     "None of the wanted host keys or keys in known_hosts files "
40e342
                     "is allowed in FIPS mode.");
40e342
             return NULL;
40e342
@@ -813,7 +813,7 @@ int ssh_kex_select_methods (ssh_session session)
40e342
     } else if (strcmp(session->next_crypto->kex_methods[SSH_KEX], "curve25519-sha256") == 0){
40e342
       session->next_crypto->kex_type=SSH_KEX_CURVE25519_SHA256;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_INFO, "Negotiated %s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Negotiated %s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
40e342
             session->next_crypto->kex_methods[SSH_KEX],
40e342
             session->next_crypto->kex_methods[SSH_HOSTKEYS],
40e342
             session->next_crypto->kex_methods[SSH_CRYPT_C_S],
40e342
@@ -1114,7 +1114,7 @@ int ssh_make_sessionid(ssh_session session)
40e342
     case SSH_KEX_ECDH_SHA2_NISTP521:
40e342
         if (session->next_crypto->ecdh_client_pubkey == NULL ||
40e342
             session->next_crypto->ecdh_server_pubkey == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARNING, "ECDH parameted missing");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "ECDH parameted missing");
40e342
             goto error;
40e342
         }
40e342
         rc = ssh_buffer_pack(buf,
40e342
diff --git a/src/knownhosts.c b/src/knownhosts.c
40e342
index f2ef088c..e632ef22 100644
40e342
--- a/src/knownhosts.c
40e342
+++ b/src/knownhosts.c
40e342
@@ -224,7 +224,7 @@ static int ssh_known_hosts_read_entries(const char *match,
40e342
 
40e342
     fp = fopen(filename, "r");
40e342
     if (fp == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Failed to open the known_hosts file '%s': %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to open the known_hosts file '%s': %s",
40e342
                 filename, strerror(errno));
40e342
         /* The missing file is not an error here */
40e342
         return SSH_OK;
40e342
@@ -483,7 +483,7 @@ static const char *ssh_known_host_sigs_from_hostkey_type(enum ssh_keytypes_e typ
40e342
 #endif
40e342
     case SSH_KEYTYPE_UNKNOWN:
40e342
     default:
40e342
-        SSH_LOG(SSH_LOG_WARN, "The given type %d is not a base private key type "
40e342
+        SSH_LOG(SSH_LOG_TRACE, "The given type %d is not a base private key type "
40e342
                 "or is unsupported", type);
40e342
         return NULL;
40e342
     }
40e342
@@ -719,7 +719,7 @@ int ssh_known_hosts_parse_line(const char *hostname,
40e342
 
40e342
     key_type = ssh_key_type_from_name(p);
40e342
     if (key_type == SSH_KEYTYPE_UNKNOWN) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "key type '%s' unknown!", p);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "key type '%s' unknown!", p);
40e342
         rc = SSH_ERROR;
40e342
         goto out;
40e342
     }
40e342
@@ -735,7 +735,7 @@ int ssh_known_hosts_parse_line(const char *hostname,
40e342
                                       key_type,
40e342
                                       &e->publickey);
40e342
     if (rc != SSH_OK) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Failed to parse %s key for entry: %s!",
40e342
                 ssh_key_type_to_char(key_type),
40e342
                 e->unparsed);
40e342
@@ -806,7 +806,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session)
40e342
     if (session->opts.knownhosts != NULL) {
40e342
         known_hosts_found = ssh_file_readaccess_ok(session->opts.knownhosts);
40e342
         if (!known_hosts_found) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Cannot access file %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Cannot access file %s",
40e342
                     session->opts.knownhosts);
40e342
         }
40e342
     }
40e342
@@ -815,7 +815,7 @@ enum ssh_known_hosts_e ssh_session_has_known_hosts_entry(ssh_session session)
40e342
         global_known_hosts_found =
40e342
                 ssh_file_readaccess_ok(session->opts.global_knownhosts);
40e342
         if (!global_known_hosts_found) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Cannot access file %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Cannot access file %s",
40e342
                     session->opts.global_knownhosts);
40e342
         }
40e342
     }
40e342
diff --git a/src/libcrypto.c b/src/libcrypto.c
40e342
index 3db75df6..c002262a 100644
40e342
--- a/src/libcrypto.c
40e342
+++ b/src/libcrypto.c
40e342
@@ -496,7 +496,7 @@ static void evp_cipher_init(struct ssh_cipher_struct *cipher) {
40e342
     case SSH_AES128_CTR:
40e342
     case SSH_AES192_CTR:
40e342
     case SSH_AES256_CTR:
40e342
-        SSH_LOG(SSH_LOG_WARNING, "This cipher is not available in evp_cipher_init");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "This cipher is not available in evp_cipher_init");
40e342
         break;
40e342
 #endif
40e342
 #ifdef HAVE_OPENSSL_EVP_AES_GCM
40e342
@@ -509,7 +509,7 @@ static void evp_cipher_init(struct ssh_cipher_struct *cipher) {
40e342
 #else
40e342
     case SSH_AEAD_AES128_GCM:
40e342
     case SSH_AEAD_AES256_GCM:
40e342
-        SSH_LOG(SSH_LOG_WARNING, "This cipher is not available in evp_cipher_init");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "This cipher is not available in evp_cipher_init");
40e342
         break;
40e342
 #endif /* HAVE_OPENSSL_EVP_AES_GCM */
40e342
     case SSH_3DES_CBC:
40e342
@@ -522,10 +522,10 @@ static void evp_cipher_init(struct ssh_cipher_struct *cipher) {
40e342
         /* ciphers not using EVP */
40e342
 #endif
40e342
     case SSH_AEAD_CHACHA20_POLY1305:
40e342
-        SSH_LOG(SSH_LOG_WARNING, "The ChaCha cipher cannot be handled here");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "The ChaCha cipher cannot be handled here");
40e342
         break;
40e342
     case SSH_NO_CIPHER:
40e342
-        SSH_LOG(SSH_LOG_WARNING, "No valid ciphertype found");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "No valid ciphertype found");
40e342
         break;
40e342
     }
40e342
 }
40e342
@@ -540,7 +540,7 @@ static int evp_cipher_set_encrypt_key(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = EVP_EncryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV);
40e342
     if (rc != 1){
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptInit_ex failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptInit_ex failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -553,7 +553,7 @@ static int evp_cipher_set_encrypt_key(struct ssh_cipher_struct *cipher,
40e342
                                  -1,
40e342
                                  (uint8_t *)IV);
40e342
         if (rc != 1) {
40e342
-            SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_SET_IV_FIXED failed");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_SET_IV_FIXED failed");
40e342
             return SSH_ERROR;
40e342
         }
40e342
     }
40e342
@@ -573,7 +573,7 @@ static int evp_cipher_set_decrypt_key(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = EVP_DecryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV);
40e342
     if (rc != 1){
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_DecryptInit_ex failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptInit_ex failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -586,7 +586,7 @@ static int evp_cipher_set_decrypt_key(struct ssh_cipher_struct *cipher,
40e342
                                  -1,
40e342
                                  (uint8_t *)IV);
40e342
         if (rc != 1) {
40e342
-            SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_SET_IV_FIXED failed");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_SET_IV_FIXED failed");
40e342
             return SSH_ERROR;
40e342
         }
40e342
     }
40e342
@@ -612,11 +612,11 @@ static void evp_cipher_encrypt(struct ssh_cipher_struct *cipher,
40e342
                            (unsigned char *)in,
40e342
                            (int)len);
40e342
     if (rc != 1){
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptUpdate failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptUpdate failed");
40e342
         return;
40e342
     }
40e342
     if (outlen != (int)len){
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "EVP_EncryptUpdate: output size %d for %zu in",
40e342
                 outlen,
40e342
                 len);
40e342
@@ -638,11 +638,11 @@ static void evp_cipher_decrypt(struct ssh_cipher_struct *cipher,
40e342
                            (unsigned char *)in,
40e342
                            (int)len);
40e342
     if (rc != 1){
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_DecryptUpdate failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptUpdate failed");
40e342
         return;
40e342
     }
40e342
     if (outlen != (int)len){
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "EVP_DecryptUpdate: output size %d for %zu in",
40e342
                 outlen,
40e342
                 len);
40e342
@@ -759,7 +759,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher,
40e342
                              1,
40e342
                              lastiv);
40e342
     if (rc == 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_IV_GEN failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_IV_GEN failed");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -771,7 +771,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher,
40e342
                            (int)aadlen);
40e342
     outlen = tmplen;
40e342
     if (rc == 0 || outlen != aadlen) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Failed to pass authenticated data");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to pass authenticated data");
40e342
         return;
40e342
     }
40e342
     memcpy(out, in, aadlen);
40e342
@@ -784,7 +784,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher,
40e342
                            (int)len - aadlen);
40e342
     outlen = tmplen;
40e342
     if (rc != 1 || outlen != (int)len - aadlen) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptUpdate failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptUpdate failed");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -793,7 +793,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher,
40e342
                           NULL,
40e342
                           &tmplen);
40e342
     if (rc < 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_EncryptFinal failed: Failed to create a tag");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptFinal failed: Failed to create a tag");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -802,7 +802,7 @@ evp_cipher_aead_encrypt(struct ssh_cipher_struct *cipher,
40e342
                              authlen,
40e342
                              (unsigned char *)tag);
40e342
     if (rc != 1) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_GET_TAG failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_GET_TAG failed");
40e342
         return;
40e342
     }
40e342
 }
40e342
@@ -830,7 +830,7 @@ evp_cipher_aead_decrypt(struct ssh_cipher_struct *cipher,
40e342
                              1,
40e342
                              lastiv);
40e342
     if (rc == 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_IV_GEN failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_IV_GEN failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -840,7 +840,7 @@ evp_cipher_aead_decrypt(struct ssh_cipher_struct *cipher,
40e342
                              authlen,
40e342
                              (unsigned char *)complete_packet + aadlen + encrypted_size);
40e342
     if (rc == 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_CTRL_GCM_SET_TAG failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_SET_TAG failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -851,7 +851,7 @@ evp_cipher_aead_decrypt(struct ssh_cipher_struct *cipher,
40e342
                            (unsigned char *)complete_packet,
40e342
                            (int)aadlen);
40e342
     if (rc == 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Failed to pass authenticated data");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to pass authenticated data");
40e342
         return SSH_ERROR;
40e342
     }
40e342
     /* Do not copy the length to the target buffer, because it is already processed */
40e342
@@ -864,12 +864,12 @@ evp_cipher_aead_decrypt(struct ssh_cipher_struct *cipher,
40e342
                            (unsigned char *)complete_packet + aadlen,
40e342
                            encrypted_size /* already substracted aadlen*/);
40e342
     if (rc != 1) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_DecryptUpdate failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptUpdate failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     if (outlen != (int)encrypted_size) {
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "EVP_DecryptUpdate: output size %d for %zd in",
40e342
                 outlen,
40e342
                 encrypted_size);
40e342
@@ -881,7 +881,7 @@ evp_cipher_aead_decrypt(struct ssh_cipher_struct *cipher,
40e342
                           NULL,
40e342
                           &outlen);
40e342
     if (rc < 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "EVP_DecryptFinal failed: Failed authentication");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptFinal failed: Failed authentication");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -1084,7 +1084,7 @@ int ssh_crypto_init(void)
40e342
         return SSH_OK;
40e342
     }
40e342
     if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER){
40e342
-        SSH_LOG(SSH_LOG_WARNING, "libssh compiled with %s "
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "libssh compiled with %s "
40e342
             "headers, currently running with %s.",
40e342
             OPENSSL_VERSION_TEXT,
40e342
             OpenSSL_version(OpenSSL_version_num())
40e342
diff --git a/src/libgcrypt.c b/src/libgcrypt.c
40e342
index 8fbf2157..9a811005 100644
40e342
--- a/src/libgcrypt.c
40e342
+++ b/src/libgcrypt.c
40e342
@@ -329,7 +329,7 @@ static int aes_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
40e342
         }
40e342
         break;
40e342
       default:
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Unksupported key length %u.", cipher->keysize);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported key length %u.", cipher->keysize);
40e342
         SAFE_FREE(cipher->key);
40e342
         return -1;
40e342
     }
40e342
@@ -420,7 +420,7 @@ aes_gcm_encrypt(struct ssh_cipher_struct *cipher,
40e342
      */
40e342
     uint64_inc(cipher->last_iv + 4);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_setiv failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_setiv failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return;
40e342
     }
40e342
@@ -428,7 +428,7 @@ aes_gcm_encrypt(struct ssh_cipher_struct *cipher,
40e342
     /* Pass the authenticated data (packet_length) */
40e342
     err = gcry_cipher_authenticate(cipher->key[0], in, aadlen);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_authenticate failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_authenticate failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return;
40e342
     }
40e342
@@ -441,7 +441,7 @@ aes_gcm_encrypt(struct ssh_cipher_struct *cipher,
40e342
                               (unsigned char *)in + aadlen,
40e342
                               len - aadlen);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_encrypt failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_encrypt failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return;
40e342
     }
40e342
@@ -451,7 +451,7 @@ aes_gcm_encrypt(struct ssh_cipher_struct *cipher,
40e342
                              (void *)tag,
40e342
                              authlen);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_gettag failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_gettag failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return;
40e342
     }
40e342
@@ -485,7 +485,7 @@ aes_gcm_decrypt(struct ssh_cipher_struct *cipher,
40e342
      */
40e342
     uint64_inc(cipher->last_iv + 4);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_setiv failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_setiv failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return SSH_ERROR;
40e342
     }
40e342
@@ -495,7 +495,7 @@ aes_gcm_decrypt(struct ssh_cipher_struct *cipher,
40e342
                                    complete_packet,
40e342
                                    aadlen);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_authenticate failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_authenticate failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return SSH_ERROR;
40e342
     }
40e342
@@ -509,7 +509,7 @@ aes_gcm_decrypt(struct ssh_cipher_struct *cipher,
40e342
                               (unsigned char *)complete_packet + aadlen,
40e342
                               encrypted_size);
40e342
     if (err) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "gcry_cipher_decrypt failed: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "gcry_cipher_decrypt failed: %s",
40e342
                 gpg_strerror(err));
40e342
         return SSH_ERROR;
40e342
     }
40e342
@@ -519,10 +519,10 @@ aes_gcm_decrypt(struct ssh_cipher_struct *cipher,
40e342
                                (unsigned char *)complete_packet + aadlen + encrypted_size,
40e342
                                authlen);
40e342
     if (gpg_err_code(err) == GPG_ERR_CHECKSUM) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "The authentication tag does not match");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "The authentication tag does not match");
40e342
         return SSH_ERROR;
40e342
     } else if (err != GPG_ERR_NO_ERROR) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "General error while decryption: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "General error while decryption: %s",
40e342
                 gpg_strerror(err));
40e342
         return SSH_ERROR;
40e342
     }
40e342
diff --git a/src/libmbedcrypto.c b/src/libmbedcrypto.c
40e342
index a2e74d3b..ee30c38a 100644
40e342
--- a/src/libmbedcrypto.c
40e342
+++ b/src/libmbedcrypto.c
40e342
@@ -468,7 +468,7 @@ cipher_init(struct ssh_cipher_struct *cipher,
40e342
     } else if (operation == MBEDTLS_DECRYPT) {
40e342
         ctx = &cipher->decrypt_ctx;
40e342
     } else {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "unknown operation");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "unknown operation");
40e342
         return 1;
40e342
     }
40e342
 
40e342
@@ -477,7 +477,7 @@ cipher_init(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = mbedtls_cipher_setup(ctx, cipher_info);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_setup failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_setup failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -485,13 +485,13 @@ cipher_init(struct ssh_cipher_struct *cipher,
40e342
                                cipher_info->key_bitlen,
40e342
                                operation);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_setkey failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_setkey failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     rc = mbedtls_cipher_set_iv(ctx, IV, cipher_info->iv_size);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_set_iv failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_set_iv failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -510,13 +510,13 @@ cipher_set_encrypt_key(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = cipher_init(cipher, MBEDTLS_ENCRYPT, key, IV);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "cipher_init failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "cipher_init failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     rc = mbedtls_cipher_reset(&cipher->encrypt_ctx);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -534,7 +534,7 @@ cipher_set_encrypt_key_cbc(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = cipher_init(cipher, MBEDTLS_ENCRYPT, key, IV);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "cipher_init failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "cipher_init failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -544,13 +544,13 @@ cipher_set_encrypt_key_cbc(struct ssh_cipher_struct *cipher,
40e342
             MBEDTLS_PADDING_NONE);
40e342
 
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_set_padding_mode failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_set_padding_mode failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     rc = mbedtls_cipher_reset(&cipher->encrypt_ctx);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -577,7 +577,7 @@ cipher_set_key_gcm(struct ssh_cipher_struct *cipher,
40e342
                             key,
40e342
                             cipher_info->key_bitlen);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_gcm_setkey failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_gcm_setkey failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -600,13 +600,13 @@ cipher_set_decrypt_key(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = cipher_init(cipher, MBEDTLS_DECRYPT, key, IV);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "cipher_init failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "cipher_init failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     mbedtls_cipher_reset(&cipher->decrypt_ctx);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -625,20 +625,20 @@ cipher_set_decrypt_key_cbc(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = cipher_init(cipher, MBEDTLS_DECRYPT, key, IV);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "cipher_init failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "cipher_init failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     rc = mbedtls_cipher_set_padding_mode(&cipher->decrypt_ctx,
40e342
             MBEDTLS_PADDING_NONE);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_set_padding_mode failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_set_padding_mode failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
     mbedtls_cipher_reset(&cipher->decrypt_ctx);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed");
40e342
         goto error;
40e342
     }
40e342
 
40e342
@@ -658,7 +658,7 @@ static void cipher_encrypt(struct ssh_cipher_struct *cipher,
40e342
     int rc = 0;
40e342
     rc = mbedtls_cipher_update(&cipher->encrypt_ctx, in, len, out, &outlen);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update failed during encryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_update failed during encryption");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -674,12 +674,12 @@ static void cipher_encrypt(struct ssh_cipher_struct *cipher,
40e342
     total_len += outlen;
40e342
 
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_finish failed during encryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_finish failed during encryption");
40e342
         return;
40e342
     }
40e342
 
40e342
     if (total_len != len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update: output size %zu for %zu",
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "mbedtls_cipher_update: output size %zu for %zu",
40e342
                 outlen, len);
40e342
         return;
40e342
     }
40e342
@@ -693,12 +693,12 @@ static void cipher_encrypt_cbc(struct ssh_cipher_struct *cipher, void *in, void
40e342
     int rc = 0;
40e342
     rc = mbedtls_cipher_update(&cipher->encrypt_ctx, in, len, out, &outlen);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update failed during encryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_update failed during encryption");
40e342
         return;
40e342
     }
40e342
 
40e342
     if (outlen != len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update: output size %zu for %zu",
40e342
+        SSH_LOG(SSH_LOG_DEBUG "mbedtls_cipher_update: output size %zu for %zu",
40e342
                 outlen, len);
40e342
         return;
40e342
     }
40e342
@@ -716,7 +716,7 @@ static void cipher_decrypt(struct ssh_cipher_struct *cipher,
40e342
 
40e342
     rc = mbedtls_cipher_update(&cipher->decrypt_ctx, in, len, out, &outlen);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update failed during decryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_update failed during decryption");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -730,14 +730,14 @@ static void cipher_decrypt(struct ssh_cipher_struct *cipher,
40e342
             outlen, &outlen);
40e342
 
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed during decryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed during decryption");
40e342
         return;
40e342
     }
40e342
 
40e342
     total_len += outlen;
40e342
 
40e342
     if (total_len != len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update: output size %zu for %zu",
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "mbedtls_cipher_update: output size %zu for %zu",
40e342
                 outlen, len);
40e342
         return;
40e342
     }
40e342
@@ -751,7 +751,7 @@ static void cipher_decrypt_cbc(struct ssh_cipher_struct *cipher, void *in, void
40e342
     int rc = 0;
40e342
     rc = mbedtls_cipher_update(&cipher->decrypt_ctx, in, len, out, &outlen);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update failed during decryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_update failed during decryption");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -770,19 +770,19 @@ static void cipher_decrypt_cbc(struct ssh_cipher_struct *cipher, void *in, void
40e342
     }
40e342
 
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_finish failed during decryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_finish failed during decryption");
40e342
         return;
40e342
     }
40e342
 
40e342
     rc = mbedtls_cipher_reset(&cipher->decrypt_ctx);
40e342
 
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_reset failed during decryption");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_cipher_reset failed during decryption");
40e342
         return;
40e342
     }
40e342
 
40e342
     if (outlen != len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_cipher_update: output size %zu for %zu",
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "mbedtls_cipher_update: output size %zu for %zu",
40e342
                 outlen, len);
40e342
         return;
40e342
     }
40e342
@@ -836,7 +836,7 @@ cipher_encrypt_gcm(struct ssh_cipher_struct *cipher,
40e342
                                    authlen,
40e342
                                    tag); /* tag */
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_gcm_crypt_and_tag failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_gcm_crypt_and_tag failed");
40e342
         return;
40e342
     }
40e342
 
40e342
@@ -870,7 +870,7 @@ cipher_decrypt_gcm(struct ssh_cipher_struct *cipher,
40e342
                                   (const uint8_t *)complete_packet + aadlen, /* input */
40e342
                                   (unsigned char *)out); /* output */
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "mbedtls_gcm_auth_decrypt failed");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "mbedtls_gcm_auth_decrypt failed");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
diff --git a/src/messages.c b/src/messages.c
40e342
index a772d488..2f4f99f8 100644
40e342
--- a/src/messages.c
40e342
+++ b/src/messages.c
40e342
@@ -160,7 +160,7 @@ static int ssh_execute_server_request(ssh_session session, ssh_message msg)
40e342
                 if (channel != NULL) {
40e342
                     rc = ssh_message_channel_request_open_reply_accept_channel(msg, channel);
40e342
                     if (rc != SSH_OK) {
40e342
-                        SSH_LOG(SSH_LOG_WARNING,
40e342
+                        SSH_LOG(SSH_LOG_TRACE,
40e342
                                 "Failed to send reply for accepting a channel "
40e342
                                 "open");
40e342
                     }
40e342
@@ -237,7 +237,7 @@ static int ssh_execute_server_request(ssh_session session, ssh_message msg)
40e342
                                                     msg->channel_request.pxwidth,
40e342
                                                     msg->channel_request.pxheight);
40e342
                     if (rc != SSH_OK) {
40e342
-                        SSH_LOG(SSH_LOG_WARNING,
40e342
+                        SSH_LOG(SSH_LOG_TRACE,
40e342
                                 "Failed to iterate callbacks for window change");
40e342
                     }
40e342
                     return SSH_OK;
40e342
@@ -494,8 +494,11 @@ ssh_message ssh_message_pop_head(ssh_session session){
40e342
 static int ssh_message_termination(void *s){
40e342
   ssh_session session = s;
40e342
   struct ssh_iterator *it;
40e342
-  if(session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+  if (session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	  // TODO not sure of this
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(session));
40e342
     return 1;
40e342
+  }
40e342
   it = ssh_list_get_iterator(session->ssh_message_list);
40e342
   if(!it)
40e342
     return 0;
40e342
@@ -774,7 +777,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_request){
40e342
 
40e342
   cmp = strcmp(service, "ssh-connection");
40e342
   if (cmp != 0) {
40e342
-      SSH_LOG(SSH_LOG_WARNING,
40e342
+      SSH_LOG(SSH_LOG_TRACE,
40e342
               "Invalid service request: %s",
40e342
               service);
40e342
       goto end;
40e342
@@ -1046,7 +1049,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
40e342
   }
40e342
 
40e342
   if (session->kbdint == NULL) {
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Warning: Got a keyboard-interactive "
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Warning: Got a keyboard-interactive "
40e342
                         "response but it seems we didn't send the request.");
40e342
 
40e342
     session->kbdint = ssh_kbdint_new();
40e342
@@ -1080,7 +1083,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
40e342
 
40e342
   if(nanswers != session->kbdint->nprompts) {
40e342
     /* warn but let the application handle this case */
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Warning: Number of prompts and answers"
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Warning: Number of prompts and answers"
40e342
                 " mismatch: p=%u a=%u", session->kbdint->nprompts, nanswers);
40e342
   }
40e342
   session->kbdint->nanswers = nanswers;
40e342
@@ -1487,7 +1490,7 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request){
40e342
     (void)type;
40e342
     (void)packet;
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,"Received SSH_MSG_GLOBAL_REQUEST packet");
40e342
+    SSH_LOG(SSH_LOG_DEBUG,"Received SSH_MSG_GLOBAL_REQUEST packet");
40e342
     r = ssh_buffer_unpack(packet, "sb",
40e342
             &request,
40e342
             &want_reply);
40e342
@@ -1519,12 +1522,12 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request){
40e342
         msg->global_request.type = SSH_GLOBAL_REQUEST_TCPIP_FORWARD;
40e342
         msg->global_request.want_reply = want_reply;
40e342
 
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Received SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request, want_reply,
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request, want_reply,
40e342
                 msg->global_request.bind_address,
40e342
                 msg->global_request.bind_port);
40e342
 
40e342
         if(ssh_callbacks_exists(session->common.callbacks, global_request_function)) {
40e342
-            SSH_LOG(SSH_LOG_PROTOCOL, "Calling callback for SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request,
40e342
+            SSH_LOG(SSH_LOG_DEBUG, "Calling callback for SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request,
40e342
                     want_reply, msg->global_request.bind_address,
40e342
                     msg->global_request.bind_port);
40e342
             session->common.callbacks->global_request_function(session, msg, session->common.callbacks->userdata);
40e342
@@ -1549,7 +1552,7 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request){
40e342
         msg->global_request.type = SSH_GLOBAL_REQUEST_CANCEL_TCPIP_FORWARD;
40e342
         msg->global_request.want_reply = want_reply;
40e342
 
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Received SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request, want_reply,
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_GLOBAL_REQUEST %s %d %s:%d", request, want_reply,
40e342
                 msg->global_request.bind_address,
40e342
                 msg->global_request.bind_port);
40e342
 
40e342
@@ -1563,14 +1566,14 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request){
40e342
     } else if(strcmp(request, "keepalive@openssh.com") == 0) {
40e342
         msg->global_request.type = SSH_GLOBAL_REQUEST_KEEPALIVE;
40e342
         msg->global_request.want_reply = want_reply;
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Received keepalive@openssh.com %d", want_reply);
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Received keepalive@openssh.com %d", want_reply);
40e342
         if(ssh_callbacks_exists(session->common.callbacks, global_request_function)) {
40e342
             session->common.callbacks->global_request_function(session, msg, session->common.callbacks->userdata);
40e342
         } else {
40e342
             ssh_message_global_request_reply_success(msg, 0);
40e342
         }
40e342
     } else {
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "UNKNOWN SSH_MSG_GLOBAL_REQUEST %s, "
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "UNKNOWN SSH_MSG_GLOBAL_REQUEST %s, "
40e342
                 "want_reply = %d", request, want_reply);
40e342
         goto reply_with_failure;
40e342
     }
40e342
@@ -1603,7 +1606,7 @@ reply_with_failure:
40e342
 error:
40e342
     SAFE_FREE(msg);
40e342
     SAFE_FREE(request);
40e342
-    SSH_LOG(SSH_LOG_WARNING, "Invalid SSH_MSG_GLOBAL_REQUEST packet");
40e342
+    SSH_LOG(SSH_LOG_TRACE, "Invalid SSH_MSG_GLOBAL_REQUEST packet");
40e342
     return rc;
40e342
 }
40e342
 
40e342
diff --git a/src/misc.c b/src/misc.c
40e342
index 0f1a7d49..0429ffac 100644
40e342
--- a/src/misc.c
40e342
+++ b/src/misc.c
40e342
@@ -622,7 +622,7 @@ void ssh_log_hexdump(const char *descr, const unsigned char *what, size_t len)
40e342
     return;
40e342
 
40e342
 error:
40e342
-    SSH_LOG(SSH_LOG_WARN, "Could not print to buffer");
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Could not print to buffer");
40e342
     return;
40e342
 }
40e342
 
40e342
@@ -1249,7 +1249,7 @@ int ssh_analyze_banner(ssh_session session, int server)
40e342
           return -1;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Analyzing banner: %s", banner);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Analyzing banner: %s", banner);
40e342
 
40e342
     switch (banner[4]) {
40e342
         case '2':
40e342
@@ -1299,7 +1299,7 @@ int ssh_analyze_banner(ssh_session session, int server)
40e342
 
40e342
             session->openssh = SSH_VERSION_INT(((int) major), ((int) minor), 0);
40e342
 
40e342
-            SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+            SSH_LOG(SSH_LOG_DEBUG,
40e342
                     "We are talking to an OpenSSH client version: %lu.%lu (%x)",
40e342
                     major, minor, session->openssh);
40e342
         }
40e342
@@ -1393,7 +1393,7 @@ int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout) {
40e342
                   * -2 means user-defined timeout as available in
40e342
                   * session->timeout, session->timeout_usec.
40e342
                   */
40e342
-            SSH_LOG(SSH_LOG_WARN, "ssh_timeout_elapsed called with -2. this needs to "
40e342
+            SSH_LOG(SSH_LOG_DEBUG, "ssh_timeout_elapsed called with -2. this needs to "
40e342
                             "be fixed. please set a breakpoint on misc.c:%d and "
40e342
                             "fix the caller\n", __LINE__);
40e342
             return 0;
40e342
@@ -1546,20 +1546,20 @@ int ssh_quote_file_name(const char *file_name, char *buf, size_t buf_len)
40e342
     enum ssh_quote_state_e state = NO_QUOTE;
40e342
 
40e342
     if (file_name == NULL || buf == NULL || buf_len == 0) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Invalid parameter");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Invalid parameter");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     /* Only allow file names smaller than 32kb. */
40e342
     if (strlen(file_name) > 32 * 1024) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "File name too long");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "File name too long");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     /* Paranoia check */
40e342
     required_buf_len = (size_t)3 * strlen(file_name) + 1;
40e342
     if (required_buf_len > buf_len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Buffer too small");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Buffer too small");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -1717,7 +1717,7 @@ int ssh_newline_vis(const char *string, char *buf, size_t buf_len)
40e342
     }
40e342
 
40e342
     if ((2 * strlen(string) + 1) > buf_len) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Buffer too small");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Buffer too small");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
diff --git a/src/packet.c b/src/packet.c
40e342
index ec4a7203..c9555ba0 100644
40e342
--- a/src/packet.c
40e342
+++ b/src/packet.c
40e342
@@ -1543,7 +1543,7 @@ SSH_PACKET_CALLBACK(ssh_packet_unimplemented){
40e342
 
40e342
     rc = ssh_buffer_unpack(packet, "d", &seq;;
40e342
     if (rc != SSH_OK) {
40e342
-        SSH_LOG(SSH_LOG_WARNING,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Could not unpack SSH_MSG_UNIMPLEMENTED packet");
40e342
     }
40e342
 
40e342
@@ -1864,7 +1864,7 @@ ssh_init_rekey_state(struct ssh_session_struct *session,
40e342
                                  session->opts.rekey_data / cipher->blocksize);
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Set rekey after %" PRIu64 " blocks",
40e342
             cipher->max_blocks);
40e342
 }
40e342
@@ -1891,7 +1891,7 @@ ssh_packet_set_newkeys(ssh_session session,
40e342
     session->next_crypto->used |= direction;
40e342
     if (session->current_crypto != NULL) {
40e342
         if (session->current_crypto->used & direction) {
40e342
-            SSH_LOG(SSH_LOG_WARNING, "This direction isn't used anymore.");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "This direction isn't used anymore.");
40e342
         }
40e342
         /* Mark the current requested direction unused */
40e342
         session->current_crypto->used &= ~direction;
40e342
@@ -1966,7 +1966,7 @@ ssh_packet_set_newkeys(ssh_session session,
40e342
                          session->next_crypto->in_cipher);
40e342
     if (session->opts.rekey_time != 0) {
40e342
         ssh_timestamp_init(&session->last_rekey_time);
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Set rekey after %" PRIu32 " seconds",
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Set rekey after %" PRIu32 " seconds",
40e342
                 session->opts.rekey_time/1000);
40e342
     }
40e342
 
40e342
diff --git a/src/packet_cb.c b/src/packet_cb.c
40e342
index 39575b17..98d21b12 100644
40e342
--- a/src/packet_cb.c
40e342
+++ b/src/packet_cb.c
40e342
@@ -87,7 +87,7 @@ SSH_PACKET_CALLBACK(ssh_packet_ignore_callback){
40e342
 	(void)user;
40e342
 	(void)type;
40e342
 	(void)packet;
40e342
-	SSH_LOG(SSH_LOG_PROTOCOL,"Received %s packet",type==SSH2_MSG_IGNORE ? "SSH_MSG_IGNORE" : "SSH_MSG_DEBUG");
40e342
+	SSH_LOG(SSH_LOG_DEBUG,"Received %s packet",type==SSH2_MSG_IGNORE ? "SSH_MSG_IGNORE" : "SSH_MSG_DEBUG");
40e342
 	/* TODO: handle a graceful disconnect */
40e342
 	return SSH_PACKET_USED;
40e342
 }
40e342
@@ -99,7 +99,7 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
40e342
   (void)packet;
40e342
   (void)user;
40e342
   (void)type;
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL, "Received SSH_MSG_NEWKEYS");
40e342
+  SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_NEWKEYS");
40e342
 
40e342
   if (session->session_state != SSH_SESSION_STATE_DH ||
40e342
       session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
40e342
@@ -158,7 +158,7 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
40e342
     if (rc == SSH_ERROR) {
40e342
       goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,"Signature verified and valid");
40e342
+    SSH_LOG(SSH_LOG_DEBUG,"Signature verified and valid");
40e342
 
40e342
     /* When receiving this packet, we switch on the incomming crypto. */
40e342
     rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_IN);
40e342
diff --git a/src/pki.c b/src/pki.c
40e342
index 932abf2c..db808355 100644
40e342
--- a/src/pki.c
40e342
+++ b/src/pki.c
40e342
@@ -330,7 +330,7 @@ enum ssh_digest_e ssh_key_hash_from_name(const char *name)
40e342
         return SSH_DIGEST_AUTO;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_WARN, "Unknown signature name %s", name);
40e342
+    SSH_LOG(SSH_LOG_TRACE, "Unknown signature name %s", name);
40e342
 
40e342
     /* TODO we should rather fail */
40e342
     return SSH_DIGEST_AUTO;
40e342
@@ -362,13 +362,13 @@ int ssh_key_algorithm_allowed(ssh_session session, const char *type)
40e342
     else if (session->server) {
40e342
         allowed_list = session->opts.wanted_methods[SSH_HOSTKEYS];
40e342
         if (allowed_list == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Session invalid: no host key available");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Session invalid: no host key available");
40e342
             return 0;
40e342
         }
40e342
     }
40e342
 #endif
40e342
     else {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Session invalid: not set as client nor server");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Session invalid: not set as client nor server");
40e342
         return 0;
40e342
     }
40e342
 
40e342
@@ -438,7 +438,7 @@ enum ssh_digest_e ssh_key_type_to_hash(ssh_session session,
40e342
     case SSH_KEYTYPE_ECDSA:
40e342
     case SSH_KEYTYPE_UNKNOWN:
40e342
     default:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Digest algorithm to be used with key type %u "
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Digest algorithm to be used with key type %u "
40e342
                 "is not defined", type);
40e342
     }
40e342
 
40e342
@@ -625,7 +625,7 @@ int ssh_key_cmp(const ssh_key k1,
40e342
     }
40e342
 
40e342
     if (k1->type != k2->type) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "key types don't match!");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "key types don't match!");
40e342
         return 1;
40e342
     }
40e342
 
40e342
@@ -744,7 +744,7 @@ int ssh_pki_import_privkey_base64(const char *b64_key,
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_INFO,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Trying to decode privkey passphrase=%s",
40e342
             passphrase ? "true" : "false");
40e342
 
40e342
@@ -864,7 +864,7 @@ int ssh_pki_import_privkey_file(const char *filename,
40e342
 
40e342
     file = fopen(filename, "rb");
40e342
     if (file == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Error opening %s: %s",
40e342
                 filename,
40e342
                 strerror(errno));
40e342
@@ -874,7 +874,7 @@ int ssh_pki_import_privkey_file(const char *filename,
40e342
     rc = fstat(fileno(file), &sb);
40e342
     if (rc < 0) {
40e342
         fclose(file);
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Error getting stat of %s: %s",
40e342
                 filename,
40e342
                 strerror(errno));
40e342
@@ -888,7 +888,7 @@ int ssh_pki_import_privkey_file(const char *filename,
40e342
     }
40e342
 
40e342
     if (sb.st_size > MAX_PRIVKEY_SIZE) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Private key is bigger than 4M.");
40e342
         fclose(file);
40e342
         return SSH_ERROR;
40e342
@@ -897,7 +897,7 @@ int ssh_pki_import_privkey_file(const char *filename,
40e342
     key_buf = malloc(sb.st_size + 1);
40e342
     if (key_buf == NULL) {
40e342
         fclose(file);
40e342
-        SSH_LOG(SSH_LOG_WARN, "Out of memory!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -906,7 +906,7 @@ int ssh_pki_import_privkey_file(const char *filename,
40e342
 
40e342
     if (size != sb.st_size) {
40e342
         SAFE_FREE(key_buf);
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Error reading %s: %s",
40e342
                 filename,
40e342
                 strerror(errno));
40e342
@@ -1068,7 +1068,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
                 rc = ssh_buffer_unpack(buffer, "SSSSS", &p, &q, &g,
40e342
                                        &pubkey, &privkey);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1109,7 +1109,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
                 rc = ssh_buffer_unpack(buffer, "SSSSSS", &n, &e, &d,
40e342
                                        &iqmp, &p, &q);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1136,7 +1136,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
                 ssh_string_burn(q);
40e342
                 SSH_STRING_FREE(q);
40e342
                 if (rc == SSH_ERROR) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build RSA private key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build RSA private key");
40e342
                     goto fail;
40e342
                 }
40e342
             }
40e342
@@ -1153,7 +1153,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
 
40e342
                 rc = ssh_buffer_unpack(buffer, "SSS", &i, &e, &exp);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1173,7 +1173,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
                 ssh_string_burn(exp);
40e342
                 SSH_STRING_FREE(exp);
40e342
                 if (rc < 0) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build ECDSA private key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build ECDSA private key");
40e342
                     goto fail;
40e342
                 }
40e342
             }
40e342
@@ -1185,7 +1185,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
 
40e342
                 rc = ssh_buffer_unpack(buffer, "SS", &pubkey, &privkey);
40e342
                 if (rc != SSH_OK){
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1194,7 +1194,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
                 SSH_STRING_FREE(privkey);
40e342
                 SSH_STRING_FREE(pubkey);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build ed25519 key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build ed25519 key");
40e342
                     goto fail;
40e342
                 }
40e342
             }
40e342
@@ -1208,7 +1208,7 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
40e342
         case SSH_KEYTYPE_RSA1:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown private key type (%d)", type);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown private key type (%d)", type);
40e342
             goto fail;
40e342
     }
40e342
 
40e342
@@ -1245,7 +1245,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
 
40e342
                 rc = ssh_buffer_unpack(buffer, "SSSS", &p, &q, &g, &pubkey);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1264,7 +1264,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
                 ssh_string_burn(pubkey);
40e342
                 SSH_STRING_FREE(pubkey);
40e342
                 if (rc == SSH_ERROR) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build DSA public key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build DSA public key");
40e342
                     goto fail;
40e342
                 }
40e342
             }
40e342
@@ -1276,7 +1276,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
 
40e342
                 rc = ssh_buffer_unpack(buffer, "SS", &e, &n);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1290,7 +1290,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
                 ssh_string_burn(n);
40e342
                 SSH_STRING_FREE(n);
40e342
                 if (rc == SSH_ERROR) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build RSA public key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build RSA public key");
40e342
                     goto fail;
40e342
                 }
40e342
             }
40e342
@@ -1307,7 +1307,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
 
40e342
                 rc = ssh_buffer_unpack(buffer, "SS", &i, &e);
40e342
                 if (rc != SSH_OK) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1321,7 +1321,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
                 ssh_string_burn(e);
40e342
                 SSH_STRING_FREE(e);
40e342
                 if (rc < 0) {
40e342
-                    SSH_LOG(SSH_LOG_WARN, "Failed to build ECDSA public key");
40e342
+                    SSH_LOG(SSH_LOG_TRACE, "Failed to build ECDSA public key");
40e342
                     goto fail;
40e342
                 }
40e342
 
40e342
@@ -1336,7 +1336,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
         {
40e342
             ssh_string pubkey = ssh_buffer_get_ssh_string(buffer);
40e342
             if (ssh_string_len(pubkey) != ED25519_KEY_LEN) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Invalid public key length");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Invalid public key length");
40e342
                 ssh_string_burn(pubkey);
40e342
                 SSH_STRING_FREE(pubkey);
40e342
                 goto fail;
40e342
@@ -1363,7 +1363,7 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
40e342
         case SSH_KEYTYPE_RSA1:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown public key protocol %d", type);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown public key protocol %d", type);
40e342
             goto fail;
40e342
     }
40e342
 
40e342
@@ -1532,26 +1532,26 @@ int ssh_pki_import_pubkey_blob(const ssh_string key_blob,
40e342
 
40e342
     buffer = ssh_buffer_new();
40e342
     if (buffer == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Out of memory!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     rc = ssh_buffer_add_data(buffer, ssh_string_data(key_blob),
40e342
             ssh_string_len(key_blob));
40e342
     if (rc < 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Out of memory!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
     type_s = ssh_buffer_get_ssh_string(buffer);
40e342
     if (type_s == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Out of memory!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
     type = ssh_key_type_from_name(ssh_string_get_char(type_s));
40e342
     if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown key type found!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown key type found!");
40e342
         goto fail;
40e342
     }
40e342
     SSH_STRING_FREE(type_s);
40e342
@@ -1602,7 +1602,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
40e342
 
40e342
     file = fopen(filename, "rb");
40e342
     if (file == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Error opening %s: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Error opening %s: %s",
40e342
                     filename, strerror(errno));
40e342
         return SSH_EOF;
40e342
     }
40e342
@@ -1610,7 +1610,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
40e342
     rc = fstat(fileno(file), &sb);
40e342
     if (rc < 0) {
40e342
         fclose(file);
40e342
-        SSH_LOG(SSH_LOG_WARN, "Error gettint stat of %s: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Error gettint stat of %s: %s",
40e342
                     filename, strerror(errno));
40e342
         switch (errno) {
40e342
             case ENOENT:
40e342
@@ -1628,7 +1628,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
40e342
     key_buf = malloc(sb.st_size + 1);
40e342
     if (key_buf == NULL) {
40e342
         fclose(file);
40e342
-        SSH_LOG(SSH_LOG_WARN, "Out of memory!");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -1637,7 +1637,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
40e342
 
40e342
     if (size != sb.st_size) {
40e342
         SAFE_FREE(key_buf);
40e342
-        SSH_LOG(SSH_LOG_WARN, "Error reading %s: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Error reading %s: %s",
40e342
                     filename, strerror(errno));
40e342
         return SSH_ERROR;
40e342
     }
40e342
@@ -1650,7 +1650,7 @@ int ssh_pki_import_pubkey_file(const char *filename, ssh_key *pkey)
40e342
         *pkey = ssh_pki_openssh_pubkey_import(key_buf);
40e342
         SAFE_FREE(key_buf);
40e342
         if (*pkey == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Failed to import public key from OpenSSH"
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Failed to import public key from OpenSSH"
40e342
                                   " private key file");
40e342
             return SSH_ERROR;
40e342
         }
40e342
@@ -2183,7 +2183,7 @@ int pki_key_check_hash_compatible(ssh_key key,
40e342
     case SSH_KEYTYPE_DSS:
40e342
         if (hash_type == SSH_DIGEST_SHA1) {
40e342
             if (ssh_fips_mode()) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "SHA1 is not allowed in FIPS mode");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "SHA1 is not allowed in FIPS mode");
40e342
                 return SSH_ERROR;
40e342
             } else {
40e342
                 return SSH_OK;
40e342
@@ -2194,7 +2194,7 @@ int pki_key_check_hash_compatible(ssh_key key,
40e342
     case SSH_KEYTYPE_RSA:
40e342
         if (hash_type == SSH_DIGEST_SHA1) {
40e342
             if (ssh_fips_mode()) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "SHA1 is not allowed in FIPS mode");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "SHA1 is not allowed in FIPS mode");
40e342
                 return SSH_ERROR;
40e342
             } else {
40e342
                 return SSH_OK;
40e342
@@ -2234,11 +2234,11 @@ int pki_key_check_hash_compatible(ssh_key key,
40e342
     case SSH_KEYTYPE_RSA1:
40e342
     case SSH_KEYTYPE_ECDSA:
40e342
     case SSH_KEYTYPE_UNKNOWN:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown key type %d", key->type);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown key type %d", key->type);
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_WARN, "Key type %d incompatible with hash type  %d",
40e342
+    SSH_LOG(SSH_LOG_TRACE, "Key type %d incompatible with hash type  %d",
40e342
             key->type, hash_type);
40e342
 
40e342
     return SSH_ERROR;
40e342
@@ -2265,7 +2265,7 @@ int ssh_pki_signature_verify(ssh_session session,
40e342
             sig->type_c);
40e342
 
40e342
     if (key_type != sig->type) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Can not verify %s signature with %s key",
40e342
                 sig->type_c, key->type_c);
40e342
         return SSH_ERROR;
40e342
diff --git a/src/pki_container_openssh.c b/src/pki_container_openssh.c
40e342
index ecde4cdd..dadeefaa 100644
40e342
--- a/src/pki_container_openssh.c
40e342
+++ b/src/pki_container_openssh.c
40e342
@@ -69,20 +69,20 @@ static int pki_openssh_import_privkey_blob(ssh_buffer key_blob_buffer,
40e342
 
40e342
     rc = ssh_buffer_unpack(key_blob_buffer, "s", &type_s);
40e342
     if (rc == SSH_ERROR){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unpack error");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unpack error");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     type = ssh_key_type_from_name(type_s);
40e342
     if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown key type '%s' found!", type_s);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown key type '%s' found!", type_s);
40e342
         return SSH_ERROR;
40e342
     }
40e342
     SAFE_FREE(type_s);
40e342
 
40e342
     rc = pki_import_privkey_buffer(type, key_blob_buffer, &key);
40e342
     if (rc != SSH_OK) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Failed to read key in OpenSSH format");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to read key in OpenSSH format");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
@@ -133,17 +133,17 @@ static int pki_private_key_decrypt(ssh_string blob,
40e342
     }
40e342
 
40e342
     if (ciphers[i].name == NULL){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported cipher %s", ciphername);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported cipher %s", ciphername);
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     cmp = strcmp(kdfname, "bcrypt");
40e342
     if (cmp != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported KDF %s", kdfname);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported KDF %s", kdfname);
40e342
         return SSH_ERROR;
40e342
     }
40e342
     if (ssh_string_len(blob) % cipher.blocksize != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Encrypted string not multiple of blocksize: %zu",
40e342
                 ssh_string_len(blob));
40e342
         return SSH_ERROR;
40e342
@@ -167,7 +167,7 @@ static int pki_private_key_decrypt(ssh_string blob,
40e342
     /* We need material for key (keysize bits / 8) and IV (blocksize)  */
40e342
     key_material_len =  cipher.keysize/8 + cipher.blocksize;
40e342
     if (key_material_len > sizeof(key_material)) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Key material too big");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Key material too big");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -181,7 +181,7 @@ static int pki_private_key_decrypt(ssh_string blob,
40e342
     if (passphrase == NULL) {
40e342
         if (auth_fn == NULL) {
40e342
             SAFE_FREE(salt);
40e342
-            SSH_LOG(SSH_LOG_WARN, "No passphrase provided");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "No passphrase provided");
40e342
             return SSH_ERROR;
40e342
         }
40e342
         rc = auth_fn("Passphrase",
40e342
@@ -251,7 +251,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
 
40e342
     cmp = strncmp(ptr, OPENSSH_HEADER_BEGIN, strlen(OPENSSH_HEADER_BEGIN));
40e342
     if (cmp != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Not an OpenSSH private key (no header)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (no header)");
40e342
         goto out;
40e342
     }
40e342
     ptr += strlen(OPENSSH_HEADER_BEGIN);
40e342
@@ -260,7 +260,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
     }
40e342
     end = strstr(ptr, OPENSSH_HEADER_END);
40e342
     if (end == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Not an OpenSSH private key (no footer)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (no footer)");
40e342
         goto out;
40e342
     }
40e342
     base64 = malloc(end - ptr + 1);
40e342
@@ -277,7 +277,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
     buffer = base64_to_bin(base64);
40e342
     SAFE_FREE(base64);
40e342
     if (buffer == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Not an OpenSSH private key (base64 error)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (base64 error)");
40e342
         goto out;
40e342
     }
40e342
     rc = ssh_buffer_unpack(buffer, "PssSdSS",
40e342
@@ -290,21 +290,21 @@ ssh_pki_openssh_import(const char *text_key,
40e342
                            &pubkey0,
40e342
                            &privkeys);
40e342
     if (rc == SSH_ERROR) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Not an OpenSSH private key (unpack error)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (unpack error)");
40e342
         goto out;
40e342
     }
40e342
     cmp = strncmp(magic, OPENSSH_AUTH_MAGIC, strlen(OPENSSH_AUTH_MAGIC));
40e342
     if (cmp != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Not an OpenSSH private key (bad magic)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (bad magic)");
40e342
         goto out;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_INFO,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Opening OpenSSH private key: ciphername: %s, kdf: %s, nkeys: %d",
40e342
             ciphername,
40e342
             kdfname,
40e342
             nkeys);
40e342
     if (nkeys != 1) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Opening OpenSSH private key: only 1 key supported (%d available)", nkeys);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Opening OpenSSH private key: only 1 key supported (%d available)", nkeys);
40e342
         goto out;
40e342
     }
40e342
 
40e342
@@ -314,7 +314,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
     if (!private) {
40e342
         rc = ssh_pki_import_pubkey_blob(pubkey0, &key);
40e342
         if (rc != SSH_OK) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Failed to import public key blob");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Failed to import public key blob");
40e342
         }
40e342
         /* in either case we clean up here */
40e342
         goto out;
40e342
@@ -343,7 +343,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
 
40e342
     rc = ssh_buffer_unpack(privkey_buffer, "dd", &checkint1, &checkint2);
40e342
     if (rc == SSH_ERROR || checkint1 != checkint2) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "OpenSSH private key unpack error (correct password?)");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "OpenSSH private key unpack error (correct password?)");
40e342
         goto out;
40e342
     }
40e342
     rc = pki_openssh_import_privkey_blob(privkey_buffer, &key);
40e342
@@ -358,7 +358,7 @@ ssh_pki_openssh_import(const char *text_key,
40e342
         if (padding != i) {
40e342
             ssh_key_free(key);
40e342
             key = NULL;
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid padding");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid padding");
40e342
             goto out;
40e342
         }
40e342
     }
40e342
@@ -407,7 +407,7 @@ static int pki_openssh_export_privkey_blob(const ssh_key privkey,
40e342
     int rc;
40e342
 
40e342
     if (privkey->type != SSH_KEYTYPE_ED25519) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Type %s not supported", privkey->type_c);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Type %s not supported", privkey->type_c);
40e342
         return SSH_ERROR;
40e342
     }
40e342
     if (privkey->ed25519_privkey == NULL ||
40e342
@@ -462,29 +462,29 @@ static int pki_private_key_encrypt(ssh_buffer privkey_buffer,
40e342
     }
40e342
 
40e342
     if (ciphers[i].name == NULL){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported cipher %s", ciphername);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported cipher %s", ciphername);
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
     cmp = strcmp(kdfname, "bcrypt");
40e342
     if (cmp != 0){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported KDF %s", kdfname);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported KDF %s", kdfname);
40e342
         return SSH_ERROR;
40e342
     }
40e342
     /* We need material for key (keysize bits / 8) and IV (blocksize)  */
40e342
     key_material_len =  cipher.keysize/8 + cipher.blocksize;
40e342
     if (key_material_len > sizeof(key_material)){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Key material too big");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Key material too big");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_WARN, "Encryption: %d key, %d IV, %d rounds, %zu bytes salt",
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Encryption: %d key, %d IV, %d rounds, %zu bytes salt",
40e342
                 cipher.keysize/8,
40e342
                 cipher.blocksize, rounds, ssh_string_len(salt));
40e342
 
40e342
     if (passphrase == NULL){
40e342
         if (auth_fn == NULL){
40e342
-            SSH_LOG(SSH_LOG_WARN, "No passphrase provided");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "No passphrase provided");
40e342
             return SSH_ERROR;
40e342
         }
40e342
         rc = auth_fn("Passphrase",
40e342
@@ -555,11 +555,11 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
40e342
         return NULL;
40e342
     }
40e342
     if (privkey->type != SSH_KEYTYPE_ED25519){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unsupported key type %s", privkey->type_c);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unsupported key type %s", privkey->type_c);
40e342
         return NULL;
40e342
     }
40e342
     if (passphrase != NULL || auth_fn != NULL){
40e342
-        SSH_LOG(SSH_LOG_INFO, "Enabling encryption for private key export");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Enabling encryption for private key export");
40e342
         to_encrypt = 1;
40e342
     }
40e342
     buffer = ssh_buffer_new();
40e342
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
40e342
index ec9cfa4b..e9fe32d3 100644
40e342
--- a/src/pki_crypto.c
40e342
+++ b/src/pki_crypto.c
40e342
@@ -587,7 +587,7 @@ int pki_key_generate_ecdsa(ssh_key key, int parameter) {
40e342
             key->type = SSH_KEYTYPE_ECDSA_P256;
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid parameter %d for ECDSA key "
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid parameter %d for ECDSA key "
40e342
                     "generation", parameter);
40e342
             return SSH_ERROR;
40e342
     }
40e342
@@ -779,7 +779,7 @@ ssh_string pki_private_key_to_pem(const ssh_key key,
40e342
             rc = 1;
40e342
             break;
40e342
 #else
40e342
-            SSH_LOG(SSH_LOG_WARN, "PEM output not supported for key type ssh-ed25519");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "PEM output not supported for key type ssh-ed25519");
40e342
             goto err;
40e342
 #endif
40e342
         case SSH_KEYTYPE_DSS_CERT01:
40e342
@@ -790,11 +790,11 @@ ssh_string pki_private_key_to_pem(const ssh_key key,
40e342
         case SSH_KEYTYPE_ED25519_CERT01:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key type %d", key->type);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key type %d", key->type);
40e342
             goto err;
40e342
     }
40e342
     if (rc != 1) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Failed to initialize EVP_PKEY structure");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to initialize EVP_PKEY structure");
40e342
         goto err;
40e342
     }
40e342
 
40e342
@@ -887,8 +887,8 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
     BIO_free(mem);
40e342
 
40e342
     if (pkey == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
-                "Parsing private key: %s",
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
+                "Error parsing private key: %s",
40e342
                 ERR_error_string(ERR_get_error(), NULL));
40e342
         return NULL;
40e342
     }
40e342
@@ -896,8 +896,8 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
     case EVP_PKEY_DSA:
40e342
         dsa = EVP_PKEY_get1_DSA(pkey);
40e342
         if (dsa == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN,
40e342
-                    "Parsing private key: %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE,
40e342
+		    "Error parsing private key: %s",
40e342
                     ERR_error_string(ERR_get_error(),NULL));
40e342
             goto fail;
40e342
         }
40e342
@@ -906,8 +906,8 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
     case EVP_PKEY_RSA:
40e342
         rsa = EVP_PKEY_get1_RSA(pkey);
40e342
         if (rsa == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN,
40e342
-                    "Parsing private key: %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE,
40e342
+		    "Error parsing private key: %s",
40e342
                     ERR_error_string(ERR_get_error(),NULL));
40e342
             goto fail;
40e342
         }
40e342
@@ -917,8 +917,8 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
 #ifdef HAVE_OPENSSL_ECC
40e342
         ecdsa = EVP_PKEY_get1_EC_KEY(pkey);
40e342
         if (ecdsa == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN,
40e342
-                    "Parsing private key: %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE,
40e342
+		    "Error parsing private key: %s",
40e342
                     ERR_error_string(ERR_get_error(), NULL));
40e342
             goto fail;
40e342
         }
40e342
@@ -927,7 +927,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
          * keys, so we need to figure out the correct type here */
40e342
         type = pki_key_ecdsa_to_key_type(ecdsa);
40e342
         if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid private key.");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid private key.");
40e342
             goto fail;
40e342
         }
40e342
 
40e342
@@ -954,7 +954,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
 
40e342
         ed25519 = malloc(key_len);
40e342
         if (ed25519 == NULL) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Out of memory");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Out of memory");
40e342
             goto fail;
40e342
         }
40e342
 
40e342
@@ -972,7 +972,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
 #endif
40e342
     default:
40e342
         EVP_PKEY_free(pkey);
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key type %d",
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key type %d",
40e342
                 EVP_PKEY_base_id(pkey));
40e342
         return NULL;
40e342
     }
40e342
@@ -1571,7 +1571,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
40e342
 #endif
40e342
         default:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature key type: %s", sig->type_c);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature key type: %s", sig->type_c);
40e342
             return NULL;
40e342
     }
40e342
 
40e342
@@ -1591,13 +1591,13 @@ static int pki_signature_from_rsa_blob(const ssh_key pubkey,
40e342
     size_t len = ssh_string_len(sig_blob);
40e342
 
40e342
     if (pubkey->rsa == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Pubkey RSA field NULL");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Pubkey RSA field NULL");
40e342
         goto errout;
40e342
     }
40e342
 
40e342
     rsalen = RSA_size(pubkey->rsa);
40e342
     if (len > rsalen) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Signature is too big: %lu > %lu",
40e342
                 (unsigned long)len,
40e342
                 (unsigned long)rsalen);
40e342
@@ -1605,7 +1605,7 @@ static int pki_signature_from_rsa_blob(const ssh_key pubkey,
40e342
     }
40e342
 
40e342
 #ifdef DEBUG_CRYPTO
40e342
-    SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "RSA signature len: %lu", (unsigned long)len);
40e342
     ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
40e342
 #endif
40e342
 
40e342
@@ -1669,7 +1669,7 @@ static int pki_signature_from_dsa_blob(UNUSED_PARAM(const ssh_key pubkey),
40e342
 
40e342
     /* 40 is the dual signature blob len. */
40e342
     if (len != 40) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Signature has wrong size: %lu",
40e342
                 (unsigned long)len);
40e342
         goto error;
40e342
@@ -1832,7 +1832,7 @@ static int pki_signature_from_ecdsa_blob(UNUSED_PARAM(const ssh_key pubkey),
40e342
     if (rlen != 0) {
40e342
         ssh_string_burn(s);
40e342
         SSH_STRING_FREE(s);
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Signature has remaining bytes in inner "
40e342
                 "sigblob: %lu",
40e342
                 (unsigned long)rlen);
40e342
@@ -1921,7 +1921,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
     int rc;
40e342
 
40e342
     if (ssh_key_type_plain(pubkey->type) != type) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Incompatible public key provided (%d) expecting (%d)",
40e342
                 type,
40e342
                 pubkey->type);
40e342
@@ -1972,7 +1972,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
 #endif
40e342
         default:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature type");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature type");
40e342
             goto error;
40e342
     }
40e342
 
40e342
diff --git a/src/pki_ed25519_common.c b/src/pki_ed25519_common.c
40e342
index 7aa05269..15c9abef 100644
40e342
--- a/src/pki_ed25519_common.c
40e342
+++ b/src/pki_ed25519_common.c
40e342
@@ -34,7 +34,7 @@ int pki_privkey_build_ed25519(ssh_key key,
40e342
     if (ssh_string_len(pubkey) != ED25519_KEY_LEN ||
40e342
         ssh_string_len(privkey) != (2 * ED25519_KEY_LEN))
40e342
     {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Invalid ed25519 key len");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Invalid ed25519 key len");
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
@@ -266,7 +266,7 @@ int pki_signature_from_ed25519_blob(ssh_signature sig, ssh_string sig_blob)
40e342
 
40e342
     len = ssh_string_len(sig_blob);
40e342
     if (len != ED25519_SIG_LEN){
40e342
-        SSH_LOG(SSH_LOG_WARN, "Invalid ssh-ed25519 signature len: %zu", len);
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Invalid ssh-ed25519 signature len: %zu", len);
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c
40e342
index bf45351d..87cd91c8 100644
40e342
--- a/src/pki_gcrypt.c
40e342
+++ b/src/pki_gcrypt.c
40e342
@@ -938,7 +938,7 @@ ssh_string pki_private_key_to_pem(const ssh_key key,
40e342
     (void) auth_fn;
40e342
     (void) auth_data;
40e342
 
40e342
-    SSH_LOG(SSH_LOG_WARN, "PEM export not supported by gcrypt backend!");
40e342
+    SSH_LOG(SSH_LOG_TRACE, "PEM export not supported by gcrypt backend!");
40e342
 
40e342
     return NULL;
40e342
 }
40e342
@@ -957,7 +957,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
 
40e342
     type = pki_privatekey_type_from_string(b64_key);
40e342
     if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key.");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key.");
40e342
         return NULL;
40e342
     }
40e342
 
40e342
@@ -977,7 +977,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
             }
40e342
 
40e342
             if (!valid) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Parsing private key");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Error parsing private key");
40e342
                 goto fail;
40e342
             }
40e342
             break;
40e342
@@ -996,7 +996,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
             }
40e342
 
40e342
             if (!valid) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Parsing private key");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Error parsing private key");
40e342
                 goto fail;
40e342
             }
40e342
             break;
40e342
@@ -1027,7 +1027,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
             }
40e342
 
40e342
             if (!valid) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Parsing private key");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Error parsing private key");
40e342
                 goto fail;
40e342
             }
40e342
 
40e342
@@ -1035,7 +1035,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
              * keys, so we need to figure out the correct type here */
40e342
             type = pki_key_ecdsa_to_key_type(ecdsa);
40e342
             if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Invalid private key.");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Invalid private key.");
40e342
                 goto fail;
40e342
             }
40e342
             break;
40e342
@@ -1045,7 +1045,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key,
40e342
         case SSH_KEYTYPE_RSA1:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key type %d", type);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key type %d", type);
40e342
             return NULL;
40e342
     }
40e342
 
40e342
@@ -1905,7 +1905,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
40e342
         case SSH_KEYTYPE_RSA1:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature key type: %d", sig->type);
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature key type: %d", sig->type);
40e342
             return NULL;
40e342
             break;
40e342
     }
40e342
@@ -1925,7 +1925,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
     int rc;
40e342
 
40e342
     if (ssh_key_type_plain(pubkey->type) != type) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Incompatible public key provided (%d) expecting (%d)",
40e342
                 type,
40e342
                 pubkey->type);
40e342
@@ -1947,7 +1947,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
         case SSH_KEYTYPE_DSS:
40e342
             /* 40 is the dual signature blob len. */
40e342
             if (len != 40) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "Signature has wrong size: %lu",
40e342
                         (unsigned long)len);
40e342
                 ssh_signature_free(sig);
40e342
@@ -1977,7 +1977,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
             rsalen = (gcry_pk_get_nbits(pubkey->rsa) + 7) / 8;
40e342
 
40e342
             if (len > rsalen) {
40e342
-                SSH_LOG(SSH_LOG_WARN,
40e342
+                SSH_LOG(SSH_LOG_TRACE,
40e342
                         "Signature is to big size: %lu",
40e342
                         (unsigned long)len);
40e342
                 ssh_signature_free(sig);
40e342
@@ -2055,7 +2055,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
                 }
40e342
 
40e342
                 if (rlen != 0) {
40e342
-                    SSH_LOG(SSH_LOG_WARN,
40e342
+                    SSH_LOG(SSH_LOG_TRACE,
40e342
                             "Signature has remaining bytes in inner "
40e342
                             "sigblob: %lu",
40e342
                             (unsigned long)rlen);
40e342
@@ -2093,7 +2093,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
         case SSH_KEYTYPE_RSA1:
40e342
         case SSH_KEYTYPE_UNKNOWN:
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature type");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature type");
40e342
             return NULL;
40e342
     }
40e342
 
40e342
@@ -2154,7 +2154,7 @@ ssh_signature pki_do_sign_hash(const ssh_key privkey,
40e342
                 break;
40e342
             case SSH_DIGEST_AUTO:
40e342
             default:
40e342
-                SSH_LOG(SSH_LOG_WARN, "Incompatible key algorithm");
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Incompatible key algorithm");
40e342
                 return NULL;
40e342
             }
40e342
             err = gcry_sexp_build(&sexp,
40e342
diff --git a/src/pki_mbedcrypto.c b/src/pki_mbedcrypto.c
40e342
index c33fb726..ca19a5fa 100644
40e342
--- a/src/pki_mbedcrypto.c
40e342
+++ b/src/pki_mbedcrypto.c
40e342
@@ -95,7 +95,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key, const char *passphrase,
40e342
 
40e342
     type = pki_privatekey_type_from_string(b64_key);
40e342
     if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key.");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key.");
40e342
         return NULL;
40e342
     }
40e342
 
40e342
@@ -136,7 +136,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key, const char *passphrase,
40e342
             if (valid != 0) {
40e342
                 char error_buf[100];
40e342
                 mbedtls_strerror(valid, error_buf, 100);
40e342
-                SSH_LOG(SSH_LOG_WARN,"Parsing private key %s", error_buf);
40e342
+                SSH_LOG(SSH_LOG_TRACE,"Parsing private key %s", error_buf);
40e342
                 goto fail;
40e342
             }
40e342
             break;
40e342
@@ -177,14 +177,14 @@ ssh_key pki_private_key_from_base64(const char *b64_key, const char *passphrase,
40e342
             if (valid != 0) {
40e342
                 char error_buf[100];
40e342
                 mbedtls_strerror(valid, error_buf, 100);
40e342
-                SSH_LOG(SSH_LOG_WARN,"Parsing private key %s", error_buf);
40e342
+                SSH_LOG(SSH_LOG_TRACE,"Parsing private key %s", error_buf);
40e342
                 goto fail;
40e342
             }
40e342
             break;
40e342
         case SSH_KEYTYPE_ED25519:
40e342
             /* Cannot open ed25519 keys with libmbedcrypto */
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown or invalid private key type %d",
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown or invalid private key type %d",
40e342
                     type);
40e342
             return NULL;
40e342
     }
40e342
@@ -213,7 +213,7 @@ ssh_key pki_private_key_from_base64(const char *b64_key, const char *passphrase,
40e342
         * keys, so we need to figure out the correct type here */
40e342
         type = pki_key_ecdsa_to_key_type(key->ecdsa);
40e342
         if (type == SSH_KEYTYPE_UNKNOWN) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Invalid private key.");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Invalid private key.");
40e342
             goto fail;
40e342
         }
40e342
     } else {
40e342
@@ -276,19 +276,19 @@ int pki_privkey_build_rsa(ssh_key key,
40e342
                                 ssh_string_data(d), ssh_string_len(d),
40e342
                                 ssh_string_data(e), ssh_string_len(e));
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Failed to import private RSA key");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to import private RSA key");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
     rc = mbedtls_rsa_complete(rsa);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Failed to complete private RSA key");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to complete private RSA key");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
     rc = mbedtls_rsa_check_privkey(rsa);
40e342
     if (rc != 0) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Inconsistent private RSA key");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Inconsistent private RSA key");
40e342
         goto fail;
40e342
     }
40e342
 
40e342
@@ -845,7 +845,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
40e342
             sig_blob = pki_ed25519_signature_to_blob(sig);
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature key type: %s",
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature key type: %s",
40e342
                     sig->type_c);
40e342
             return NULL;
40e342
     }
40e342
@@ -865,20 +865,20 @@ static ssh_signature pki_signature_from_rsa_blob(const ssh_key pubkey, const
40e342
     size_t len = ssh_string_len(sig_blob);
40e342
 
40e342
     if (pubkey->rsa == NULL) {
40e342
-        SSH_LOG(SSH_LOG_WARN, "Pubkey RSA field NULL");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Pubkey RSA field NULL");
40e342
         goto errout;
40e342
     }
40e342
 
40e342
     rsalen = mbedtls_pk_get_bitlen(pubkey->rsa) / 8;
40e342
     if (len > rsalen) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Signature is too big: %lu > %lu",
40e342
                 (unsigned long) len,
40e342
                 (unsigned long) rsalen);
40e342
         goto errout;
40e342
     }
40e342
 #ifdef DEBUG_CRYPTO
40e342
-    SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len);
40e342
+    SSH_LOG(SSH_LOG_TRACE, "RSA signature len: %lu", (unsigned long)len);
40e342
     ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
40e342
 #endif
40e342
 
40e342
@@ -919,7 +919,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
     int rc;
40e342
 
40e342
     if (ssh_key_type_plain(pubkey->type) != type) {
40e342
-        SSH_LOG(SSH_LOG_WARN,
40e342
+        SSH_LOG(SSH_LOG_TRACE,
40e342
                 "Incompatible public key provided (%d) expecting (%d)",
40e342
                 type,
40e342
                 pubkey->type);
40e342
@@ -1003,7 +1003,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
             }
40e342
 
40e342
             if (rlen != 0) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "Signature has remaining bytes in inner "
40e342
+                SSH_LOG(SSH_LOG_TRACE, "Signature has remaining bytes in inner "
40e342
                         "sigblob: %lu",
40e342
                         (unsigned long)rlen);
40e342
                 ssh_signature_free(sig);
40e342
@@ -1020,7 +1020,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
40e342
             }
40e342
             break;
40e342
         default:
40e342
-            SSH_LOG(SSH_LOG_WARN, "Unknown signature type");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Unknown signature type");
40e342
             return NULL;
40e342
     }
40e342
 
40e342
@@ -1050,7 +1050,7 @@ static ssh_string rsa_do_sign_hash(const unsigned char *digest,
40e342
         break;
40e342
     case SSH_DIGEST_AUTO:
40e342
     default:
40e342
-        SSH_LOG(SSH_LOG_WARN, "Incompatible key algorithm");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Incompatible key algorithm");
40e342
         return NULL;
40e342
     }
40e342
 
40e342
diff --git a/src/scp.c b/src/scp.c
40e342
index 85d670a4..d3f9a831 100644
40e342
--- a/src/scp.c
40e342
+++ b/src/scp.c
40e342
@@ -140,7 +140,7 @@ int ssh_scp_init(ssh_scp scp)
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Initializing scp session %s %son location '%s'",
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Initializing scp session %s %son location '%s'",
40e342
             scp->mode == SSH_SCP_WRITE?"write":"read",
40e342
             scp->recursive ? "recursive " : "",
40e342
             scp->location);
40e342
@@ -364,7 +364,7 @@ int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode)
40e342
         goto error;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "SCP pushing directory %s with permissions '%s'",
40e342
             vis_encoded, perms);
40e342
 
40e342
@@ -501,7 +501,7 @@ int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size,
40e342
         goto error;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "SCP pushing file %s, size %" PRIu64 " with permissions '%s'",
40e342
             vis_encoded, size, perms);
40e342
 
40e342
@@ -800,7 +800,7 @@ int ssh_scp_pull_request(ssh_scp scp)
40e342
         *p = '\0';
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Received SCP request: '%s'", buffer);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Received SCP request: '%s'", buffer);
40e342
     switch(buffer[0]) {
40e342
     case 'C':
40e342
         /* File */
40e342
diff --git a/src/server.c b/src/server.c
40e342
index 841a1c42..acfbfffe 100644
40e342
--- a/src/server.c
40e342
+++ b/src/server.c
40e342
@@ -348,7 +348,7 @@ static void ssh_server_connection_callback(ssh_session session){
40e342
                 goto error;
40e342
             }
40e342
             set_status(session, 0.4f);
40e342
-            SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+            SSH_LOG(SSH_LOG_DEBUG,
40e342
                     "SSH client banner: %s", session->clientbanner);
40e342
 
40e342
             /* Here we analyze the different protocols the server allows. */
40e342
@@ -884,7 +884,7 @@ int ssh_message_auth_interactive_request(ssh_message msg, const char *name,
40e342
 
40e342
   /* fill in the kbdint structure */
40e342
   if (msg->session->kbdint == NULL) {
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Warning: Got a "
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Warning: Got a "
40e342
                                         "keyboard-interactive response but it "
40e342
                                         "seems we didn't send the request.");
40e342
 
40e342
@@ -981,13 +981,13 @@ int ssh_auth_reply_success(ssh_session session, int partial)
40e342
 
40e342
     crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
40e342
     if (crypto != NULL && crypto->delayed_compress_out) {
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Enabling delayed compression OUT");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression OUT");
40e342
         crypto->do_compress_out = 1;
40e342
     }
40e342
 
40e342
     crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
40e342
     if (crypto != NULL && crypto->delayed_compress_in) {
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Enabling delayed compression IN");
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression IN");
40e342
         crypto->do_compress_in = 1;
40e342
     }
40e342
     return r;
40e342
diff --git a/src/session.c b/src/session.c
40e342
index 3199096a..fe87cadd 100644
40e342
--- a/src/session.c
40e342
+++ b/src/session.c
40e342
@@ -504,11 +504,14 @@ int ssh_is_blocking(ssh_session session)
40e342
 /* Waits until the output socket is empty */
40e342
 static int ssh_flush_termination(void *c){
40e342
   ssh_session session = c;
40e342
-  if (ssh_socket_buffered_write_bytes(session->socket) == 0 ||
40e342
-      session->session_state == SSH_SESSION_STATE_ERROR)
40e342
+  if (ssh_socket_buffered_write_bytes(session->socket) == 0) {
40e342
     return 1;
40e342
-  else
40e342
+  } else if (session->session_state == SSH_SESSION_STATE_ERROR) {
40e342
+	SSH_LOG(SSH_LOG_WARN, "Error: %s", ssh_get_error(session));
40e342
+    return 1;
40e342
+  } else {
40e342
     return 0;
40e342
+  }
40e342
 }
40e342
 
40e342
 /**
40e342
@@ -1184,7 +1187,7 @@ int ssh_get_publickey_hash(const ssh_key key,
40e342
 
40e342
             /* In FIPS mode, we cannot use MD5 */
40e342
             if (ssh_fips_mode()) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "In FIPS mode MD5 is not allowed."
40e342
+                SSH_LOG(SSH_LOG_TRACE, "In FIPS mode MD5 is not allowed."
40e342
                                       "Try using SSH_PUBLICKEY_HASH_SHA256");
40e342
                 rc = SSH_ERROR;
40e342
                 goto out;
40e342
diff --git a/src/sftp.c b/src/sftp.c
40e342
index a8346040..e3a842d5 100644
40e342
--- a/src/sftp.c
40e342
+++ b/src/sftp.c
40e342
@@ -316,7 +316,7 @@ int sftp_server_init(sftp_session sftp){
40e342
   }
40e342
   SSH_BUFFER_FREE(reply);
40e342
 
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL, "Server version sent");
40e342
+  SSH_LOG(SSH_LOG_DEBUG, "Server version sent");
40e342
 
40e342
   if (version > LIBSFTP_VERSION) {
40e342
     sftp->version = LIBSFTP_VERSION;
40e342
@@ -707,7 +707,7 @@ int sftp_init(sftp_session sftp) {
40e342
       sftp_set_error(sftp, SSH_FX_FAILURE);
40e342
       return -1;
40e342
   }
40e342
-  SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+  SSH_LOG(SSH_LOG_DEBUG,
40e342
       "SFTP server version %d",
40e342
       version);
40e342
   rc = ssh_buffer_unpack(packet->payload, "s", &ext_name);
40e342
@@ -720,7 +720,7 @@ int sftp_init(sftp_session sftp) {
40e342
       break;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
         "SFTP server extension: %s, version: %s",
40e342
         ext_name, ext_data);
40e342
 
40e342
@@ -1353,7 +1353,7 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
40e342
         if (rc != SSH_OK){
40e342
             goto error;
40e342
         }
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL, "Name: %s", attr->name);
40e342
+        SSH_LOG(SSH_LOG_DEBUG, "Name: %s", attr->name);
40e342
 
40e342
         /* Set owner and group if we talk to openssh and have the longname */
40e342
         if (ssh_get_openssh_version(sftp->session)) {
40e342
@@ -1373,7 +1373,7 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
40e342
     if (rc != SSH_OK){
40e342
         goto error;
40e342
     }
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+    SSH_LOG(SSH_LOG_DEBUG,
40e342
             "Flags: %.8"PRIx32"\n", (uint32_t) attr->flags);
40e342
 
40e342
     if (attr->flags & SSH_FILEXFER_ATTR_SIZE) {
40e342
@@ -1381,7 +1381,7 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
40e342
         if(rc != SSH_OK) {
40e342
             goto error;
40e342
         }
40e342
-        SSH_LOG(SSH_LOG_PROTOCOL,
40e342
+        SSH_LOG(SSH_LOG_DEBUG,
40e342
                 "Size: %"PRIu64"\n",
40e342
                 (uint64_t) attr->size);
40e342
     }
40e342
@@ -1644,7 +1644,7 @@ sftp_attributes sftp_readdir(sftp_session sftp, sftp_dir dir)
40e342
         return NULL;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Count is %d", dir->count);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Count is %d", dir->count);
40e342
 
40e342
     attr = sftp_parse_attr(sftp, dir->buffer, 1);
40e342
     if (attr == NULL) {
40e342
diff --git a/src/socket.c b/src/socket.c
40e342
index 2fef8e7e..f470bb28 100644
40e342
--- a/src/socket.c
40e342
+++ b/src/socket.c
40e342
@@ -473,12 +473,12 @@ void ssh_socket_close(ssh_socket s)
40e342
         kill(pid, SIGTERM);
40e342
         while (waitpid(pid, &status, 0) == -1) {
40e342
             if (errno != EINTR) {
40e342
-                SSH_LOG(SSH_LOG_WARN, "waitpid failed: %s", strerror(errno));
40e342
+                SSH_LOG(SSH_LOG_TRACE, "waitpid failed: %s", strerror(errno));
40e342
                 return;
40e342
             }
40e342
         }
40e342
         if (!WIFEXITED(status)) {
40e342
-            SSH_LOG(SSH_LOG_WARN, "Proxy command exitted abnormally");
40e342
+            SSH_LOG(SSH_LOG_TRACE, "Proxy command exitted abnormally");
40e342
             return;
40e342
         }
40e342
         SSH_LOG(SSH_LOG_TRACE, "Proxy command returned %d", WEXITSTATUS(status));
40e342
@@ -849,7 +849,7 @@ int ssh_socket_connect(ssh_socket s,
40e342
         return SSH_ERROR;
40e342
     }
40e342
     fd = ssh_connect_host_nonblocking(s->session, host, bind_addr, port);
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Nonblocking connection socket: %d", fd);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Nonblocking connection socket: %d", fd);
40e342
     if (fd == SSH_INVALID_SOCKET) {
40e342
         return SSH_ERROR;
40e342
     }
40e342
@@ -873,7 +873,7 @@ ssh_execute_command(const char *command, socket_t in, socket_t out)
40e342
     /* Prepare /dev/null socket for the stderr redirection */
40e342
     int devnull = open("/dev/null", O_WRONLY);
40e342
     if (devnull == -1) {
40e342
-        SSH_LOG(SSH_LOG_WARNING, "Failed to open /dev/null");
40e342
+        SSH_LOG(SSH_LOG_TRACE, "Failed to open /dev/null");
40e342
         exit(1);
40e342
     }
40e342
 
40e342
@@ -914,7 +914,7 @@ ssh_socket_connect_proxycommand(ssh_socket s, const char *command)
40e342
         return SSH_ERROR;
40e342
     }
40e342
 
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "Executing proxycommand '%s'", command);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "Executing proxycommand '%s'", command);
40e342
     pid = fork();
40e342
     if (pid == 0) {
40e342
         ssh_execute_command(command, pair[0], pair[0]);
40e342
@@ -922,7 +922,7 @@ ssh_socket_connect_proxycommand(ssh_socket s, const char *command)
40e342
     }
40e342
     s->proxy_pid = pid;
40e342
     close(pair[0]);
40e342
-    SSH_LOG(SSH_LOG_PROTOCOL, "ProxyCommand connection pipe: [%d,%d]",pair[0],pair[1]);
40e342
+    SSH_LOG(SSH_LOG_DEBUG, "ProxyCommand connection pipe: [%d,%d]",pair[0],pair[1]);
40e342
     ssh_socket_set_fd(s, pair[1]);
40e342
     s->state=SSH_SOCKET_CONNECTED;
40e342
     s->fd_is_socket=0;