List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:com.alibaba.stonelab.javalab.misc.Misc2.java
public static void main(String[] args) throws Exception { Log LOG = LogFactory.getLog(Misc2.class); MDC.put("ip", "127.0.0.1"); MDC.put("user", "stone2083"); LOG.error("OK"); MDC.remove("ip"); MDC.remove("user"); }
From source file:com.sazneo.export.formatter.Main.java
public static void main(String... args) { Log logger = LogFactory.getLog(Main.class); if (args.length != 3) { logger.error("Usage: java Main <stylesheet> <export xml file> <output dir>"); System.exit(1);//from w ww .j a va 2 s.c o m } String styleSheetPath = args[0]; File styleSheet = new File(styleSheetPath); String exportXmlPath = args[1]; File exportXml = new File(exportXmlPath); String outPutDirPath = args[2]; File outputDir = new File(outPutDirPath); if (!outputDir.exists()) { outputDir.mkdirs(); } try { File outputFile = new File(outputDir, "export.html"); FileOutputStream outputStream = new FileOutputStream(outputFile); HtmlFormatter formatter = new HtmlFormatter(styleSheet, exportXml, outputStream); formatter.transform(); FileProcessor fileProcessor = new FileProcessor(exportXml, outputDir); fileProcessor.process(); } catch (IOException e) { logger.error(MessageFormat.format("Failed to create export.html at {0}:\n {1}", outPutDirPath, e)); } }
From source file:LoggingTrial.java
public static void main(String[] args) { Log log = LogFactory.getLog(LoggingTrial.class); System.out.println("The Log being used >>> " + log); Exception e = new Exception("A DUMMY EXCEPTION"); if (log.isTraceEnabled()) { log.trace("TRACE TEST"); log.trace("TRACE TEST", e); }/*from w w w.j a v a2 s .c o m*/ if (log.isDebugEnabled()) { log.debug("DEBUG TEST"); log.debug("DEBUG TEST", e); } if (log.isInfoEnabled()) { log.info("INFO TEST"); log.info("INFO TEST", e); } if (log.isWarnEnabled()) { log.warn("WARN TEST"); log.warn("WARN TEST", e); } if (log.isErrorEnabled()) { log.error("ERROR TEST"); log.error("ERROR TEST", e); } if (log.isFatalEnabled()) { log.fatal("FATAL TEST"); log.fatal("FATAL TEST", e); } }
From source file:com.joliciel.csvLearner.utils.LogUtils.java
/** Log the exception passed.// w w w. jav a 2s . c o m */ public static void logError(Log logger, Throwable e) { logger.error(e); logger.error(LogUtils.getErrorString(e)); }
From source file:com.ngdata.sep.util.io.Closer.java
public static void close(Object object) { if (object != null) { try {//w w w . j av a2 s . co m Method closeMethod = null; Method[] methods = object.getClass().getMethods(); for (Method method : methods) { if (method.getParameterTypes().length == 0) { if (method.getName().equals("close")) { closeMethod = method; break; } else if (method.getName().equals("shutdown")) { closeMethod = method; } else if (method.getName().equals("stop")) { closeMethod = method; } } } if (closeMethod != null) { closeMethod.invoke(object); } else { Log log = LogFactory.getLog(Closer.class); log.error("Do not know how to close object of type " + object.getClass().getName()); } } catch (Throwable t) { Log log = LogFactory.getLog(Closer.class); log.error("Error closing object of type " + object.getClass().getName(), t); } } }
From source file:com.nineteendrops.tracdrops.client.core.MessageUtils.java
public static String registerErrorLog(Log log, String key, String... parameters) { String errorMessage = getMessage(key, parameters); log.error(errorMessage); return errorMessage; }
From source file:com.microsoft.tfs.sdk.samples.console.LogConfigurationSample.java
private static void logAllLevels(final Log log, final String message) { log.trace(message);//from w ww . ja va2 s. c o m log.debug(message); log.info(message); log.warn(message); log.error(message); log.fatal(message); }
From source file:gov.nih.nci.ncicb.tcga.dcc.common.webservice.WebServiceUtil.java
/** * Log the given error message and throw a <code>WebApplicationException</code> with the given HTTP status code * * @param log the <code>Log</code> to use for the logging * @param errorMessage the error message to log and display in the <code>WebApplicationException</code> * @param httpStatusCode the HTTP status code to set for the <code>WebApplicationException</code> *//*from w w w .j a v a 2 s . c o m*/ public static void logAndThrowWebApplicationException(final Log log, final String errorMessage, final int httpStatusCode) { log.error(errorMessage); throw new WebApplicationException(getStatusResponse(httpStatusCode, errorMessage)); }
From source file:com.oncore.calorders.core.utils.Logger.java
/** * Writes a error log entry if it is enabled * * @author OnCore Consulting LLC/*from w w w. j a v a 2 s . c o m*/ * * @param log a handle to the log * @param message the text to log */ public static void error(final Log log, final String message) { if (log != null && message != null) { log.error(message); } }
From source file:com.buffalokiwi.api.APILog.java
/** * Log a message with error log level.// ww w . j a v a2s.c o m * * @param log Log to write to * @param message log this message */ public static void error(final Log log, final Object... message) { if (log.isErrorEnabled()) log.error(concat(message)); }