@Override
	public Message<?> preSend(Message<?> message, MessageChannel channel) {
		try {
			Object logMessage = ExpressionUtil.parse(expression, message);
			if (logMessage instanceof Throwable) {
				StringWriter stringWriter = new StringWriter();
				((Throwable) logMessage).printStackTrace(new PrintWriter(stringWriter, true));
				logMessage = stringWriter.toString();
			}
			switch (this.level) {
				case ERROR :
					logger.error(LOG_PATTERN , channel, logMessage);
					break;
				case WARN :
					logger.warn(LOG_PATTERN , channel, logMessage);
					break;
				case INFO :
					logger.info(LOG_PATTERN , channel, logMessage);
					break;
				case DEBUG :
					logger.debug(LOG_PATTERN , channel, logMessage);
					break;
			}
		} catch (Exception e) {
			logger.error("Could not log information for message '" + message + "'", e);
		}
		return message;
	}