Java Code Examples for org.apache.commons.logging.Log#error()
The following examples show how to use
org.apache.commons.logging.Log#error() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Log4jConfigurerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void doTestInitLogging(String location, boolean refreshInterval) throws FileNotFoundException { if (refreshInterval) { Log4jConfigurer.initLogging(location, 10); } else { Log4jConfigurer.initLogging(location); } Log log = LogFactory.getLog(this.getClass()); log.debug("debug"); log.info("info"); log.warn("warn"); log.error("error"); log.fatal("fatal"); assertTrue(MockLog4jAppender.loggingStrings.contains("debug")); assertTrue(MockLog4jAppender.loggingStrings.contains("info")); assertTrue(MockLog4jAppender.loggingStrings.contains("warn")); assertTrue(MockLog4jAppender.loggingStrings.contains("error")); assertTrue(MockLog4jAppender.loggingStrings.contains("fatal")); Log4jConfigurer.shutdownLogging(); assertTrue(MockLog4jAppender.closeCalled); }
Example 2
Source File: BaseExpectedException.java From live-chat-engine with Apache License 2.0 | 6 votes |
public static void logError(Log log, Throwable t, String msg){ NoLog noLog = t.getClass().getAnnotation(NoLog.class); if(noLog != null){ return; } if(t instanceof BaseExpectedException) { log.error(msg+": "+t); return; } IOException socketEx = SocketUtil.findSocketException(t); if(socketEx != null){ log.error(msg+": "+new ExpectedSocketException(socketEx, t)); return; } //not ExpectedException log.error(msg, t); }
Example 3
Source File: ConfigFileFinder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public boolean readFile(Reader reader, String readFrom, String path, String baseUrl, Log log) { // At the moment it is assumed the file is Json, but that does not need to be the case. // We have the path including extension. boolean successReadingConfig = true; try { JsonNode jsonNode = jsonObjectMapper.readValue(reader, JsonNode.class); String readFromMessage = readFrom + ' ' + path; if (log.isTraceEnabled()) { log.trace(readFromMessage + " config is: " + jsonNode); } else { log.debug(readFromMessage + " config read"); } readJson(jsonNode, readFromMessage, baseUrl); } catch (Exception e) { log.error("Error reading "+path, e); successReadingConfig = false; } return successReadingConfig; }
Example 4
Source File: RestApiUtil.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Logs the error, builds a BadRequestException with specified details and throws it * * @param errorHandlers A List of error handler objects containing the error information * @param log Log instance * @throws BadRequestException */ public static void handleBadRequest(List<ErrorHandler> errorHandlers, Log log) throws BadRequestException { BadRequestException badRequestException = buildBadRequestException(errorHandlers); StringBuilder builder = new StringBuilder(); for (int i = 0; i < errorHandlers.size(); i++) { ErrorHandler handler = errorHandlers.get(i); builder.append(handler.getErrorMessage()); if (StringUtils.isNotBlank(handler.getErrorDescription())) { builder.append(":"); builder.append(handler.getErrorDescription()); } if (i < errorHandlers.size() - 1) { builder.append(", "); } } log.error(builder.toString()); throw badRequestException; }
Example 5
Source File: RestApiUtil.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Logs the error, builds a ConflictException with specified details and throws it * * @param description description of the error * @param log Log instance * @throws ConflictException */ public static void handleResourceAlreadyExistsError(String description, Log log) throws ConflictException { ConflictException conflictException = buildConflictException( RestApiConstants.STATUS_CONFLICT_MESSAGE_RESOURCE_ALREADY_EXISTS, description); log.error(description); throw conflictException; }
Example 6
Source File: VfsLog.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * error. * * @param vfsLog The base component Logger to use. * @param commonsLog The class specific Logger * @param message The message to log. */ public static void error(final Log vfsLog, final Log commonsLog, final String message) { if (vfsLog != null) { vfsLog.error(message); } else if (commonsLog != null) { commonsLog.error(message); } }
Example 7
Source File: DlqPartitionFunction.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
/** * Determine the fallback function to use based on the dlq partition count if no * {@link DlqPartitionFunction} bean is provided. * @param dlqPartitions the partition count. * @param logger the logger. * @return the fallback. */ static DlqPartitionFunction determineFallbackFunction(@Nullable Integer dlqPartitions, Log logger) { if (dlqPartitions == null) { return ORIGINAL_PARTITION; } else if (dlqPartitions > 1) { logger.error("'dlqPartitions' is > 1 but a custom DlqPartitionFunction bean is not provided"); return ORIGINAL_PARTITION; } else { return PARTITION_ZERO; } }
Example 8
Source File: CallerInformationTest.java From logging-log4j2 with Apache License 2.0 | 5 votes |
@Test public void testClassLogger() throws Exception { final ListAppender app = ctx.getListAppender("Class").clear(); final Log logger = LogFactory.getLog("ClassLogger"); logger.info("Ignored message contents."); logger.warn("Verifying the caller class is still correct."); logger.error("Hopefully nobody breaks me!"); final List<String> messages = app.getMessages(); assertEquals("Incorrect number of messages.", 3, messages.size()); for (final String message : messages) { assertEquals("Incorrect caller class name.", this.getClass().getName(), message); } }
Example 9
Source File: LogUtil.java From sofa-acts with Apache License 2.0 | 5 votes |
/** * Print critical error message with red * @param log * @param message */ public static void printColoredError(Log log, String message) { if (ActsConfiguration.getInstance().isColoredLog()) { String tmp = replaceCrLf(message); log.error(colorMultiLine(AnsiColorConstants.ANSI_RED_BEGIN, tmp)); } else { log.error(message); } }
Example 10
Source File: TestConfigurationLogger.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether an exception can be logged on error level. */ @Test public void testErrorWithException() { final Log log = EasyMock.createMock(Log.class); final Throwable ex = new Exception("Test exception"); log.error(MSG, ex); EasyMock.replay(log); final ConfigurationLogger logger = new ConfigurationLogger(log); logger.error(MSG, ex); EasyMock.verify(log); }
Example 11
Source File: LogUtils.java From spatial-framework-for-hadoop with Apache License 2.0 | 4 votes |
public static void Log_VariableArgumentLengthXY(Log logger){ logger.error(messages[MSG_ARGUMENT_LENGTH_XY]); }
Example 12
Source File: LogUtils.java From alfresco-bulk-import with Apache License 2.0 | 4 votes |
public final static void error(final Log log, final String message) { log.error(PREFIX + message); }
Example 13
Source File: FileUtil.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private static void logError(String message) { Log logger = LogFactory.getLog(FileUtil.class); logger.error(message); }
Example 14
Source File: LogUtils.java From spatial-framework-for-hadoop with Apache License 2.0 | 4 votes |
public static void Log_InvalidType(Log logger, OGCType expecting, OGCType actual){ logger.error(String.format(messages[MSG_INVALID_TYPE], expecting, actual)); }
Example 15
Source File: LogUtils.java From spatial-framework-for-hadoop with Apache License 2.0 | 4 votes |
public static void Log_InvalidText(Log logger, String text) { int limit = text.length(); limit = limit > 80 ? 80 : limit; logger.error(String.format(messages[MSG_INVALID_TEXT], text.substring(0, limit))); }
Example 16
Source File: RestApiUtil.java From carbon-apimgt with Apache License 2.0 | 3 votes |
/** * Logs the error, builds a internalServerErrorException with specified details and throws it * * @param msg error message * @param t Throwable instance * @param log Log instance * @throws InternalServerErrorException */ public static void handleInternalServerError(String msg, Throwable t, Log log) throws InternalServerErrorException { InternalServerErrorException internalServerErrorException = buildInternalServerErrorException(msg); log.error(msg, t); throw internalServerErrorException; }
Example 17
Source File: RestApiUtil.java From carbon-apimgt with Apache License 2.0 | 3 votes |
/** * Logs the error, builds a internalServerErrorException with specified details and throws it * * @param msg error message * @param log Log instance * @throws InternalServerErrorException */ public static void handleInternalServerError(String msg, Log log) throws InternalServerErrorException { InternalServerErrorException internalServerErrorException = buildInternalServerErrorException(); log.error(msg); throw internalServerErrorException; }
Example 18
Source File: VfsLog.java From commons-vfs with Apache License 2.0 | 3 votes |
/** * error. * * @param vfsLog The base component Logger to use. * @param commonsLog The class specific Logger * @param message The message to log. * @param t The exception, if any. */ public static void error(final Log vfsLog, final Log commonsLog, final String message, final Throwable t) { if (vfsLog != null) { vfsLog.error(message, t); } else if (commonsLog != null) { commonsLog.error(message, t); } }
Example 19
Source File: ActsLogUtil.java From sofa-acts with Apache License 2.0 | 2 votes |
/** * print error without exceptino message * * @param logger * @param message */ public static void error(Log logger, String message) { logger.error(message); addProcessLog(message); }
Example 20
Source File: LogUtil.java From alfresco-core with GNU Lesser General Public License v3.0 | 2 votes |
/** * Log an I18Nized message to ERROR. * * @param logger the logger to use * @param messageKey the message key * @param args the required message arguments */ public static final void error(Log logger, String messageKey, Object ... args) { logger.error(I18NUtil.getMessage(messageKey, args)); }