List of usage examples for org.apache.commons.logging Log error
void error(Object message, Throwable t);
From source file:edu.vt.middleware.ldap.LdapTLSSocketFactory.java
/** * This returns the default SSL socket factory. * * @return <code>SocketFactory</code> */// w w w . j a v a 2s .c o m public static SocketFactory getDefault() { final LdapTLSSocketFactory sf = new LdapTLSSocketFactory(); try { sf.initialize(); } catch (IOException e) { final Log logger = LogFactory.getLog(LdapTLSSocketFactory.class); if (logger.isErrorEnabled()) { logger.error("Error loading keystore", e); } } catch (GeneralSecurityException e) { final Log logger = LogFactory.getLog(LdapTLSSocketFactory.class); if (logger.isErrorEnabled()) { logger.error("Error initializing socket factory", e); } } return sf; }
From source file:it.cnr.icar.eric.client.ui.thin.OutputExceptions.java
/** * Log exceptions and display them to user in a consistent fashion. * * @param log Log where error or warning should be output * @param logMsg Context message to log with t * @param displayMsg Context message to display to user with t * @param t Throwable to log about and optionally display * @param display Output information about this Throwable on page? * @param warning If true, log warning rather than error *//* ww w . j a v a2s . com*/ private static void display(Log log, String logMsg, String displayMsg, Throwable t, boolean display, boolean warning) { // When not given a Msg, should we provide context for cause? boolean needContext = (null != t.getMessage() && null != t.getCause()); // Log a fair amount of information unconditionally if (null == logMsg && null != displayMsg) { logMsg = displayMsg; } if (log.isDebugEnabled()) { // Include full traceback in logging output if (null == logMsg) { if (warning) { log.warn(t.toString(), t); } else { log.error(t.toString(), t); } } else { if (warning) { log.warn(logMsg, t); } else { log.error(logMsg, t); } } } else { if (null == logMsg) { if (needContext) { if (warning) { log.warn(t.toString()); } else { log.error(t.toString()); } } } else { if (warning) { log.warn(logMsg); } else { log.error(logMsg); } } if (warning) { log.error(getCause(t, true)); } else { log.error(getCause(t, true)); } } // Conditionally display a subset of the above information to the user if (display) { FacesContext context = FacesContext.getCurrentInstance(); FacesMessage.Severity severity = (warning ? FacesMessage.SEVERITY_ERROR : FacesMessage.SEVERITY_WARN); if (null == displayMsg && null != logMsg) { displayMsg = logMsg; } if (null == displayMsg) { if (needContext) { context.addMessage(null, new FacesMessage(severity, goodMessage(t), null)); } } else { context.addMessage(null, new FacesMessage(severity, displayMsg, null)); } context.addMessage(null, new FacesMessage(severity, getCause(t, false), null)); } }
From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java
public static String getLogFormatSqlStatement(String sql, Object args, Log log) { try {/*from w w w .j ava2 s.com*/ if (args instanceof Map) { Map<String, Object> map = (Map<String, Object>) args; TreeMap<String, Object> treeMap = new TreeMap<String, Object>(stringComparator); treeMap.putAll(map); Iterator<Entry<String, Object>> iter = treeMap.entrySet().iterator(); while (iter.hasNext()) { Entry<String, Object> entry = iter.next(); sql = sql.replace(":" + entry.getKey(), getLogFormatArgument(entry.getValue())); } } else if (args instanceof Object[]) { Object[] objs = (Object[]) args; for (Object obj : objs) { sql = StringUtils.replaceOnce(sql, "?", getLogFormatArgument(obj)); } } } catch (Throwable t) { if (log.isDebugEnabled()) log.error(t, t); else log.error(t); } return sql; }
From source file:br.octa.exception.LoggedRuntimeException.java
/** * Logs the given message and the root error and create a RuntimeException object * * @param msg Error Message//from w w w . j a v a 2 s .c om * @param throwable Root Error * @param log Logger who need to consume message */ public LoggedRuntimeException(String msg, Throwable throwable, Log log) { super(msg, throwable); log.error(msg, throwable); }
From source file:es.mityc.firmaJava.libreria.xades.elementos.EncodingEnum.java
private EncodingEnum(String uri) { try {// w w w . ja v a 2 s .c om this.uri = new URI(uri); } catch (URISyntaxException ex) { Log logger = LogFactory.getLog(EncodingEnum.class); logger.error("Error creando enumerado de encoding", ex); } }
From source file:com.springsource.insight.plugin.logging.CommonsLoggingOperationCollectionAspectTest.java
@Test public void testLogErrorMessageWithException() { String msg = "testLogErrorMessageWithException"; Log logger = LogFactory.getLog(getClass()); Throwable t = new IllegalArgumentException(msg); logger.error(msg, t); assertLoggingOperation(Log.class, "ERROR", msg, t); }
From source file:net.sf.nmedit.jtheme.image.ToolkitImageResource.java
@Override public Image getImage(int width, int height) { if (!(imageInitialized)) { imageInitialized = true;// ww w .j a v a 2 s . co m try { image = ImageIO.read(getEnsureResolvedURL()); } catch (IOException e) { Log log = LogFactory.getLog(getClass()); if (log.isErrorEnabled()) log.error("getImage() failed", e); } } return image; }
From source file:hadoopInstaller.logging.CompositeLog.java
@Override public void error(Object message, Throwable t) { for (Log log : this.logs) { log.error(message, t); }/*w w w . j a va 2s .c om*/ }
From source file:io.netty.logging.CommonsLoggerTest.java
@Test public void testErrorWithException() { Log mock = createStrictMock(Log.class); mock.error("a", e); replay(mock);//ww w. ja v a 2s .co m InternalLogger logger = new CommonsLogger(mock, "foo"); logger.error("a", e); verify(mock); }
From source file:interactivespaces.sandbox.service.control.opensoundcontrol.internal.OpenSoundControlMethodCollection.java
/** * Handle a packet./*from ww w . java2 s . c o m*/ * * @param packet * the packet to handle * @param log * a logger to use */ public void handlePacket(OpenSoundControlServerPacket packet, Log log) { for (OpenSoundControlMethod method : methods) { try { method.invoke(packet); } catch (Throwable e) { log.error("An Open Sound Control method has failed", e); } } }