List of usage examples for org.apache.commons.logging Log debug
void debug(Object message, Throwable t);
From source file:org.alfresco.extension.bulkimport.util.LogUtils.java
public final static void debug(final Log log, final Throwable cause) { log.debug(RAW_EXCEPTION, cause); }
From source file:org.amplafi.flow.impl.FlowStateLoggerImpl.java
public void debug(Log logger, Object message, Throwable throwable) { if (logger == null) { logger = getLog();// ww w. ja va 2 s. c o m } StringBuilder stringBuilder = getFlowStatesString(message); logger.debug(stringBuilder, throwable); }
From source file:org.apache.james.transport.mailets.jsieve.FileIntoAction.java
/** * <p>//from w w w . j a v a2 s .com * Executes the passed ActionFileInto. * </p> * * <p> * This implementation accepts any destination with the root of <code>INBOX</code>. * </p> * * <p> * As the current POP3 server does not support sub-folders, the mail is * stored in the INBOX for the recipient of the mail and the full intended * destination added as a prefix to the message's subject. * </p> * * <p> * When IMAP support is added to James, it will be possible to support * sub-folders of <code>INBOX</code> fully. * </p> * * @param anAction * @param aMail * @param context not null * @throws MessagingException */ public void execute(ActionFileInto anAction, Mail aMail, final ActionContext context) throws MessagingException { String destinationMailbox = anAction.getDestination(); MailAddress recipient; boolean delivered = false; try { recipient = ActionUtils.getSoleRecipient(aMail); if (!(destinationMailbox.length() > 0 && destinationMailbox.charAt(0) == HIERARCHY_DELIMITER)) { destinationMailbox = HIERARCHY_DELIMITER + destinationMailbox; } final String mailbox = destinationMailbox.replace(HIERARCHY_DELIMITER, '/'); final String url = "mailbox://" + recipient.asString() + mailbox; //TODO: copying this message so many times seems a waste context.post(url, aMail); delivered = true; } catch (MessagingException ex) { final Log log = context.getLog(); if (log.isDebugEnabled()) { log.debug("Error while storing mail into. " + destinationMailbox, ex); } throw ex; } if (delivered) { final Log log = context.getLog(); if (log.isDebugEnabled()) { log.debug("Filed Message ID: " + aMail.getMessage().getMessageID() + " into destination: \"" + destinationMailbox + "\""); } } }
From source file:org.apache.jsieve.mailet.FileIntoAction.java
/** * <p>//from ww w. j a v a 2 s .c o m * Executes the passed ActionFileInto. * </p> * * <p> * This implementation accepts any destination with the root of <code>INBOX</code>. * </p> * * <p> * As the current POP3 server does not support sub-folders, the mail is * stored in the INBOX for the recipient of the mail and the full intended * destination added as a prefix to the message's subject. * </p> * * <p> * When IMAP support is added to James, it will be possible to support * sub-folders of <code>INBOX</code> fully. * </p> * * @param anAction * @param aMail * @param context not null * @throws MessagingException */ @SuppressWarnings("deprecation") public void execute(ActionFileInto anAction, Mail aMail, final ActionContext context) throws MessagingException { String destinationMailbox = anAction.getDestination(); MailAddress recipient; boolean delivered = false; try { recipient = ActionUtils.getSoleRecipient(aMail); MimeMessage localMessage = createMimeMessage(aMail, recipient); if (!(destinationMailbox.length() > 0 && destinationMailbox.charAt(0) == HIERARCHY_DELIMITER)) { destinationMailbox = HIERARCHY_DELIMITER + destinationMailbox; } final String mailbox = destinationMailbox.replace(HIERARCHY_DELIMITER, '/'); final String host; if (mailbox.charAt(0) == '/') { host = "@localhost"; } else { host = "@localhost/"; } final String url = "mailbox://" + recipient.getUser() + host + mailbox; //TODO: copying this message so many times seems a waste context.post(url, localMessage); delivered = true; } catch (MessagingException ex) { final Log log = context.getLog(); if (log.isDebugEnabled()) { log.debug("Error while storing mail into. " + destinationMailbox, ex); } throw ex; } finally { // Ensure the mail is always ghosted aMail.setState(Mail.GHOST); } if (delivered) { final Log log = context.getLog(); if (log.isDebugEnabled()) { log.debug("Filed Message ID: " + aMail.getMessage().getMessageID() + " into destination: \"" + destinationMailbox + "\""); } } }
From source file:org.apache.poi.util.MethodUtils.java
/** * Try to make the method accessible//from w w w.j av a2 s . c o m * @param method The source arguments */ private static void setMethodAccessible(Object method) { try { // // XXX Default access superclass workaround // // When a public class has a default access superclass // with public methods, these methods are accessible. // Calling them from compiled code works fine. // // Unfortunately, using reflection to invoke these methods // seems to (wrongly) to prevent access even when the method // modifer is public. // // The following workaround solves the problem but will only // work from sufficiently privilages code. // // Better workarounds would be greatfully accepted. // if (method instanceof Method) { ((Method) method).setAccessible(true); } else if (method instanceof Constructor) { ((Constructor) method).setAccessible(true); } else { throw new RuntimeException("invalid parameter"); } } catch (SecurityException se) { // log but continue just in case the method.invoke works anyway Log log = LogFactory.getLog(MethodUtils.class); if (!loggedAccessibleWarning) { boolean vulnerableJVM = false; try { String specVersion = System.getProperty("java.specification.version"); if (specVersion.charAt(0) == '1' && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || specVersion.charAt(2) == '3')) { vulnerableJVM = true; } } catch (SecurityException e) { // don't know - so display warning vulnerableJVM = true; } if (vulnerableJVM) { log.warn("Current Security Manager restricts use of workarounds for reflection bugs " + " in pre-1.4 JVMs."); } loggedAccessibleWarning = true; } log.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", se); } }
From source file:org.displaytag.exception.BaseNestableJspTagException.java
/** * Instantiate a new BaseNestableJspTagException. * @param source Class where the exception is generated * @param message message// www . j a va2 s. c om * @param cause previous Exception */ public BaseNestableJspTagException(Class source, String message, Throwable cause) { super(message); this.sourceClass = source; this.nestedException = cause; // log exception Log log = LogFactory.getLog(source); // choose appropriate logging method if (getSeverity() == SeverityEnum.DEBUG) { log.debug(toString(), cause); } else if (getSeverity() == SeverityEnum.INFO) { log.info(toString(), cause); } else if (getSeverity() == SeverityEnum.WARN) { log.warn(toString(), cause); } else { // error - default log.error(toString(), cause); } }
From source file:org.displaytag.exception.BaseNestableRuntimeException.java
/** * Instantiate a new BaseNestableRuntimeException. * @param source Class where the exception is generated * @param message message//from w ww . j a v a2 s. c o m * @param cause previous Exception */ public BaseNestableRuntimeException(Class source, String message, Throwable cause) { super(message); this.sourceClass = source; this.nestedException = cause; // log exception Log log = LogFactory.getLog(source); // choose appropriate logging method if (getSeverity() == SeverityEnum.DEBUG) { log.debug(toString(), cause); } else if (getSeverity() == SeverityEnum.INFO) { log.info(toString(), cause); } else if (getSeverity() == SeverityEnum.WARN) { log.warn(toString(), cause); } else { // error - default log.error(toString(), cause); } }
From source file:org.easyrec.utils.spring.log.LoggerUtils.java
/** * Writes the given 'message' to the Log 'logger' with level 'logLevel'. * * @param logger the Log to which the message is written * @param logLevel the level to which the message is written * @param message the message to be written * @param ta a Throwable passed on to the Log *//*from w ww . j a va 2 s . c om*/ public static void log(Log logger, String logLevel, String message, Throwable ta) { if (logLevel.equalsIgnoreCase("info")) { if (logger.isInfoEnabled()) { logger.info(message, ta); } } else if (logLevel.equalsIgnoreCase("debug")) { if (logger.isDebugEnabled()) { logger.debug(message, ta); } } else if (logLevel.equalsIgnoreCase("error")) { if (logger.isErrorEnabled()) { logger.error(message, ta); } } else if (logLevel.equalsIgnoreCase("trace")) { if (logger.isTraceEnabled()) { logger.trace(message, ta); } } else if (logLevel.equalsIgnoreCase("warn")) { if (logger.isWarnEnabled()) { logger.warn(message, ta); } } else if (logLevel.equalsIgnoreCase("fatal")) { if (logger.isFatalEnabled()) { logger.fatal(message, ta); } } else { logger.error("Passed unknown log level " + logLevel + " to Aspect - logging to error instead!"); logger.error(message, ta); } }
From source file:org.elasticsearch.client.RequestLogger.java
/** * Logs a request that failed//from ww w . j a v a2s. c om */ static void logFailedRequest(Log logger, HttpUriRequest request, HttpHost host, Exception e) { if (logger.isDebugEnabled()) { logger.debug( "request [" + request.getMethod() + " " + host + getUri(request.getRequestLine()) + "] failed", e); } if (tracer.isTraceEnabled()) { String traceRequest; try { traceRequest = buildTraceRequest(request, host); } catch (IOException e1) { tracer.trace("error while reading request for trace purposes", e); traceRequest = ""; } tracer.trace(traceRequest); } }
From source file:org.hyperic.hq.plugin.mssql.MsSQLDetector.java
protected static void debug(Log _log, String msg, Exception ex) { if (_log.isDebugEnabled()) { _log.debug(msg.replaceAll("(-P,? ?)([^ ,]+)", "$1******").replaceAll("(pass[^=]*=)(\\w*)", "$1******"), ex);/* www . j ava 2 s. c om*/ } }