GUAC-915: Clean up all log messages within Guacamole.

This commit is contained in:
Michael Jumper
2014-10-30 17:12:54 -07:00
parent 4a5efe4819
commit 48382b8285
17 changed files with 93 additions and 78 deletions

View File

@@ -113,7 +113,7 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
// Get configuration file
File configFile = getConfigurationFile();
logger.info("Reading configuration file: {}", configFile);
logger.debug("Reading configuration file: \"{}\"", configFile);
// Parse document
try {
@@ -135,10 +135,10 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
}
catch (IOException e) {
throw new GuacamoleServerException("Error reading configuration file: " + e.getMessage(), e);
throw new GuacamoleServerException("Error reading configuration file.", e);
}
catch (SAXException e) {
throw new GuacamoleServerException("Error parsing XML file: " + e.getMessage(), e);
throw new GuacamoleServerException("Error parsing XML file.", e);
}
}
@@ -153,7 +153,7 @@ public class NoAuthenticationProvider extends SimpleAuthenticationProvider {
// If modified recently, gain exclusive access and recheck
synchronized (this) {
if (configFile.exists() && configTime < configFile.lastModified()) {
logger.info("Config file {} has been modified.", configFile);
logger.debug("Configuration file \"{}\" has been modified.", configFile);
init(); // If still not up to date, re-init
}
}

View File

@@ -417,7 +417,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
}
catch (IOException e) {

View File

@@ -119,7 +119,7 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint {
}
catch (GuacamoleException e) {
logger.error("Connection failed: {}", e.getMessage());
logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
logger.debug("Error connecting WebSocket tunnel.", e);
closeConnection(session, e.getStatus());
return;
@@ -177,16 +177,17 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint {
// to pass within the WebSocket connection, logging
// each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.info("WebSocket connection terminated: {}", e.getMessage());
logger.debug("WebSocket connection terminated due to client error.", e);
closeConnection(session, e.getStatus());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
closeConnection(session, GuacamoleStatus.SUCCESS);
}
catch (GuacamoleException e) {
logger.error("Connection terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection.", e);
logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection to guacd.", e);
closeConnection(session, e.getStatus());
}
@@ -213,10 +214,10 @@ public abstract class GuacamoleWebSocketTunnelEndpoint extends Endpoint {
writer.write(message.toCharArray());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
}
catch (GuacamoleException e) {
logger.debug("Tunnel write failed.", e);
logger.debug("WebSocket tunnel write failed.", e);
}
tunnel.releaseWriter();

View File

@@ -101,7 +101,7 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide
(user_mapping_file.exists()
&& mod_time < user_mapping_file.lastModified())) {
logger.info("Reading user mapping file: {}", user_mapping_file);
logger.debug("Reading user mapping file: \"{}\"", user_mapping_file);
// Parse document
try {

View File

@@ -116,8 +116,8 @@ public class AuthenticatingFilter implements Filter {
}
catch (GuacamoleException e) {
logger.error("Unable to read Guacamole configuration: {}", e.getMessage());
logger.debug("Error reading Guacamole configuration.", e);
logger.error("Unable to read guacamole.properties: {}", e.getMessage());
logger.debug("Error reading guacamole.properties.", e);
throw new ServletException(e);
}
@@ -364,7 +364,7 @@ public class AuthenticatingFilter implements Filter {
}
else
logger.warn("Invalid HTTP Basic \"Authorization\" header received.");
logger.info("Invalid HTTP Basic \"Authorization\" header received.");
}
@@ -398,9 +398,16 @@ public class AuthenticatingFilter implements Filter {
// If auth failed, notify listeners
if (context == null) {
if (logger.isWarnEnabled())
logger.warn("Authentication attempt from {} for user \"{}\" failed.",
getLoggableAddress(request), credentials.getUsername());
if (logger.isWarnEnabled()) {
// Only bother logging failures involving usernames
if (credentials.getUsername() != null)
logger.info("Authentication attempt from {} for user \"{}\" failed.",
getLoggableAddress(request), credentials.getUsername());
else
logger.debug("Authentication attempt from {} without username failed.",
getLoggableAddress(request));
}
notifyFailed(listeners, credentials);
}
@@ -425,12 +432,13 @@ public class AuthenticatingFilter implements Filter {
// Catch any thrown guacamole exception and attempt to pass within the
// HTTP response, logging each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.info("HTTP request rejected: {}", e.getMessage());
logger.debug("HTTP request rejected by AuthenticatingFilter.", e);
sendError(response, e.getStatus(), e.getMessage());
}
catch (GuacamoleException e) {
logger.error("Authentication failed internally: {}", e.getMessage());
logger.debug("Internal server error.", e);
logger.debug("Internal server error during authentication.", e);
sendError(response, e.getStatus(), "Internal server error.");
}

View File

@@ -45,11 +45,14 @@ public class BasicGuacamoleTunnelServlet extends GuacamoleHTTPTunnelServlet {
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
// Warn of lack of WebSocket
logger.warn("Using HTTP tunnel (not WebSocket). Performance may be sub-optimal.");
// Attempt to create HTTP tunnel
GuacamoleTunnel tunnel = BasicTunnelRequestUtility.createTunnel(new HTTPTunnelRequest(request));
// If successful, warn of lack of WebSocket
logger.info("Using HTTP tunnel (not WebSocket). Performance may be sub-optimal.");
return tunnel;
return BasicTunnelRequestUtility.createTunnel(new HTTPTunnelRequest(request));
}
}

View File

@@ -45,7 +45,7 @@ public class BasicLogin extends RestrictedHttpServlet {
protected void restrictedService(
UserContext context,
HttpServletRequest request, HttpServletResponse response) {
logger.info("Login was successful.");
logger.debug("Login was successful for user \"{}\".", context.self().getUsername());
}
}

View File

@@ -164,7 +164,7 @@ public class BasicTunnelRequestUtility {
listeners = new SessionListenerCollection(httpSession);
}
catch (GuacamoleException e) {
logger.error("Authentication canceled: failed to retrieve listeners: {}", e.getMessage());
logger.error("Creation of tunnel to guacd aborted: Failed to retrieve listeners: {}", e.getMessage());
logger.debug("Error retrieving listeners.", e);
throw e;
}
@@ -235,13 +235,13 @@ public class BasicTunnelRequestUtility {
// Get authorized connection
Connection connection = directory.get(id);
if (connection == null) {
logger.warn("Connection id={} not found.", id);
logger.info("Connection \"{}\" does not exist for user \"{}\".", id, context.self().getUsername());
throw new GuacamoleSecurityException("Requested connection is not authorized.");
}
// Connect socket
socket = connection.connect(info);
logger.info("Successful connection to \"{}\".", id);
logger.info("User \"{}\" successfully connected to \"{}\".", context.self().getUsername(), id);
break;
}
@@ -255,13 +255,13 @@ public class BasicTunnelRequestUtility {
// Get authorized connection group
ConnectionGroup group = directory.get(id);
if (group == null) {
logger.warn("Connection group id={} not found.", id);
logger.info("Connection group \"{}\" does not exist for user \"{}\".", id, context.self().getUsername());
throw new GuacamoleSecurityException("Requested connection group is not authorized.");
}
// Connect socket
socket = group.connect(info);
logger.info("Successful connection to group \"{}\".", id);
logger.info("User \"{}\" successfully connected to group \"{}\".", context.self().getUsername(), id);
break;
}
@@ -283,7 +283,8 @@ public class BasicTunnelRequestUtility {
return new MonitoringGuacamoleReader(clipboard, super.acquireReader());
}
catch (GuacamoleException e) {
logger.warn("Clipboard integration disabled due to error.", e);
logger.warn("Clipboard integration failed to initialize: {}", e.getMessage());
logger.debug("Error setting up clipboard integration.", e);
}
// Pass through by default.
@@ -307,7 +308,7 @@ public class BasicTunnelRequestUtility {
// Notify listeners about connection
if (!notifyConnect(listeners, context, credentials, tunnel)) {
logger.info("Connection canceled by listener.");
logger.info("Successful connection canceled by hook.");
return null;
}

View File

@@ -77,7 +77,7 @@ public class RestrictedFilter implements Filter {
final GuacamoleStatus status = GuacamoleStatus.CLIENT_UNAUTHORIZED;
final String message = "Not authenticated";
logger.warn("Client request rejected: {}", message);
logger.info("HTTP request rejected: {}", message);
response.addHeader("Guacamole-Status-Code", Integer.toString(status.getGuacamoleStatusCode()));
response.addHeader("Guacamole-Error-Message", message);
response.sendError(status.getHttpStatusCode());

View File

@@ -118,7 +118,7 @@ public abstract class RestrictedHttpServlet extends HttpServlet {
// Catch any thrown guacamole exception and attempt to pass within the
// HTTP response, logging each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.debug("HTTP request rejected by RestrictedHttpServlet.", e);
sendError(response, e.getStatus(), e.getMessage());
}
catch (GuacamoleUnsupportedException e) {
@@ -126,8 +126,8 @@ public abstract class RestrictedHttpServlet extends HttpServlet {
sendError(response, e.getStatus(), e.getMessage());
}
catch (GuacamoleException e) {
logger.error("Request failed: {}", e.getMessage());
logger.debug("Internal server error.", e);
logger.error("HTTP request failed: {}", e.getMessage());
logger.debug("Internal server error while handling HTTP request to restricted resource.", e);
sendError(response, e.getStatus(), "Internal server error.");
}

View File

@@ -47,7 +47,7 @@ public class SessionKeepAlive extends RestrictedHttpServlet {
HttpServletRequest request, HttpServletResponse response) {
// Do nothing
logger.trace("Keep-alive signal received.");
logger.debug("Keep-alive signal received from user \"{}\".", context.self().getUsername());
}

View File

@@ -249,7 +249,7 @@ public class List extends RestrictedHttpServlet {
}
catch (IOException e) {
logger.error("Unable to read \"{}\": {}", file.getAbsolutePath(), e.getMessage());
logger.error("Unable to read connection parameter information from \"{}\": {}", file.getAbsolutePath(), e.getMessage());
logger.debug("Error reading protocol XML.", e);
}

View File

@@ -66,6 +66,8 @@ public class LogbackInitializer implements ServletContextListener {
logger.info("Loading logback configuration from \"{}\".", logbackConfiguration);
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.reset();
try {
// Initialize logback

View File

@@ -181,7 +181,7 @@ public class WebSocketSupportLoader implements ServletContextListener {
}
// Warn of lack of WebSocket
logger.debug("WebSocket support NOT present. Only HTTP will be used.");
logger.info("WebSocket support NOT present. Only HTTP will be used.");
}

View File

@@ -79,7 +79,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel = doConnect(request);
}
catch (GuacamoleException e) {
logger.error("Connection failed: {}", e.getMessage());
logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
logger.debug("Error connecting WebSocket tunnel.", e);
return null;
}
@@ -96,10 +96,10 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
writer.write(string.toCharArray());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
}
catch (GuacamoleException e) {
logger.debug("Tunnel write failed.", e);
logger.debug("WebSocket tunnel write failed.", e);
}
tunnel.releaseWriter();
@@ -150,22 +150,23 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
// to pass within the WebSocket connection, logging
// each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.info("WebSocket connection terminated: {}", e.getMessage());
logger.debug("WebSocket connection terminated due to client error.", e);
closeConnection(connection, e.getStatus());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
closeConnection(connection, GuacamoleStatus.SUCCESS);
}
catch (GuacamoleException e) {
logger.error("Connection terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection.", e);
logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection to guacd.", e);
closeConnection(connection, e.getStatus());
}
}
catch (IOException e) {
logger.debug("Tunnel read failed due to I/O error.", e);
logger.debug("WebSocket tunnel read failed due to I/O error.", e);
}
}
@@ -183,7 +184,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
logger.debug("Unable to close connection to guacd.", e);
}
}

View File

@@ -107,7 +107,7 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe
}
catch (GuacamoleException e) {
logger.error("Connection failed: {}", e.getMessage());
logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
logger.debug("Error connecting WebSocket tunnel.", e);
closeConnection(session, e.getStatus());
return;
@@ -163,16 +163,17 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe
// to pass within the WebSocket connection, logging
// each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.info("WebSocket connection terminated: {}", e.getMessage());
logger.debug("WebSocket connection terminated due to client error.", e);
closeConnection(session, e.getStatus());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
closeConnection(session, GuacamoleStatus.SUCCESS);
}
catch (GuacamoleException e) {
logger.error("Connection terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection.", e);
logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection to guacd.", e);
closeConnection(session, e.getStatus());
}
@@ -199,10 +200,10 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe
writer.write(message.toCharArray());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
}
catch (GuacamoleException e) {
logger.debug("Tunnel write failed.", e);
logger.debug("WebSocket tunnel write failed.", e);
}
tunnel.releaseWriter();
@@ -224,7 +225,7 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
logger.debug("Unable to close connection to guacd.", e);
}
}
@@ -238,7 +239,7 @@ public abstract class GuacamoleWebSocketTunnelListener implements WebSocketListe
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
logger.debug("Unable to close connection to guacd.", e);
}
}

View File

@@ -65,14 +65,16 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
*
* @param outbound The outbound WebSocket connection to close.
* @param guac_status The status to send.
* @throws IOException If an error prevents proper closure of the WebSocket
* connection.
*/
public static void closeConnection(WsOutbound outbound,
GuacamoleStatus guac_status) throws IOException {
public void closeConnection(WsOutbound outbound, GuacamoleStatus guac_status) {
byte[] message = Integer.toString(guac_status.getGuacamoleStatusCode()).getBytes("UTF-8");
outbound.close(guac_status.getWebSocketCode(), ByteBuffer.wrap(message));
try {
byte[] message = Integer.toString(guac_status.getGuacamoleStatusCode()).getBytes("UTF-8");
outbound.close(guac_status.getWebSocketCode(), ByteBuffer.wrap(message));
}
catch (IOException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
}
}
@@ -99,7 +101,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel = doConnect(request);
}
catch (GuacamoleException e) {
logger.error("Connection failed: {}", e.getMessage());
logger.error("Creation of WebSocket tunnel to guacd failed: {}", e.getMessage());
logger.debug("Error connecting WebSocket tunnel.", e);
return null;
}
@@ -123,10 +125,10 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
}
catch (GuacamoleException e) {
logger.debug("Tunnel write failed.", e);
logger.debug("WebSocket tunnel write failed.", e);
}
tunnel.releaseWriter();
@@ -137,12 +139,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
// Do not start connection if tunnel does not exist
if (tunnel == null) {
try {
closeConnection(outbound, GuacamoleStatus.RESOURCE_NOT_FOUND);
}
catch (IOException e) {
logger.debug("Tunnel not found, but unable to signal closure of WebSocket.", e);
}
closeConnection(outbound, GuacamoleStatus.RESOURCE_NOT_FOUND);
return;
}
@@ -182,16 +179,17 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
// to pass within the WebSocket connection, logging
// each error appropriately.
catch (GuacamoleClientException e) {
logger.warn("Client request rejected: {}", e.getMessage());
logger.info("WebSocket connection terminated: {}", e.getMessage());
logger.debug("WebSocket connection terminated due to client error.", e);
closeConnection(outbound, e.getStatus());
}
catch (GuacamoleConnectionClosedException e) {
logger.debug("Connection closed.", e);
logger.debug("Connection to guacd closed.", e);
closeConnection(outbound, GuacamoleStatus.SUCCESS);
}
catch (GuacamoleException e) {
logger.error("Connection terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection.", e);
logger.error("Connection to guacd terminated abnormally: {}", e.getMessage());
logger.debug("Internal error during connection to guacd.", e);
closeConnection(outbound, e.getStatus());
}
@@ -215,7 +213,7 @@ public abstract class GuacamoleWebSocketTunnelServlet extends WebSocketServlet {
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close WebSocket tunnel.", e);
logger.debug("Unable to close connection to guacd.", e);
}
}