Java Code Examples for org.slf4j.Logger.error()

The following are Jave code examples for showing how to use error() of the org.slf4j.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: fresco_floodlight   File: InstructionUtils.java   View Source Code Vote up 6 votes
/**
 * Convert the string representation of an OFInstructionMeter to
 * an OFInstructionMeter. The instruction will be set within the
 * OFFlowMod.Builder provided. Notice nothing is returned, but the
 * side effect is the addition of an instruction in the OFFlowMod.Builder.
 * @param fmb; The FMB in which to append the new instruction
 * @param instStr; The string to parse the instruction from
 * @param log
 */
public static void meterFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
	if (inst == null || inst.isEmpty()) {
		return;
	}

	if (fmb.getVersion().compareTo(OFVersion.OF_13) < 0) {
		log.error("Goto Meter Instruction not supported in OpenFlow 1.0, 1.1, or 1.2");
		return;
	}

	OFInstructionMeter.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildMeter();

	if (inst.startsWith("0x")) {
		ib.setMeterId(Long.valueOf(inst.replaceFirst("0x", ""), 16));
	} else {
		ib.setMeterId(Long.valueOf(inst));
	}		

	log.debug("Appending (Goto)Meter instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());
}
 
Example 2
Project: lams   File: Configuration.java   View Source Code Vote up 6 votes
/**
 * Validates that the system is not using the horribly buggy Sun JAXP implementation.
 */
public static void validateNonSunJAXP() {
    Logger log = getLogger();
    String builderFactoryClass = DocumentBuilderFactory.newInstance().getClass().getName();
    log.debug("VM using JAXP parser {}", builderFactoryClass);

    if (builderFactoryClass.startsWith("com.sun")) {
        String errorMsg = "\n\n\nOpenSAML requires an xml parser that supports JAXP 1.3 and DOM3.\n"
                + "The JVM is currently configured to use the Sun XML parser, which is known\n"
                + "to be buggy and can not be used with OpenSAML.  Please endorse a functional\n"
                + "JAXP library(ies) such as Xerces and Xalan.  For instructions on how to endorse\n"
                + "a new parser see http://java.sun.com/j2se/1.5.0/docs/guide/standards/index.html\n\n\n";

        log.error(errorMsg);
        throw new Error(errorMsg);
    }
}
 
Example 3
Project: Hydrograph   File: ClassDetails.java   View Source Code Vote up 6 votes
public ClassDetails(SourceType javaClassFile, String jarFileName, String packageName, boolean isUserDefined) {
	Logger LOGGER = LogFactory.INSTANCE.getLogger(ClassDetails.class);
	LOGGER.debug("Extracting methods from " + cName);

	try {
		this.javaDoc=getJavaDoc(javaClassFile);			
		intialize(javaClassFile, jarFileName, packageName, isUserDefined);
		for (IJavaElement iJavaElement : javaClassFile.getChildren()) {
			if (iJavaElement instanceof SourceMethod) {
				addMethodsToClass((IMethod) iJavaElement);
			}
		}
	} catch (JavaModelException e) {
		LOGGER.error("Error occurred while fetching methods from class" + cName);
	}
}
 
Example 4
Project: lams   File: SigningUtil.java   View Source Code Vote up 6 votes
/**
 * Compute the Message Authentication Code (MAC) value over the supplied input.
 * 
 * It is up to the caller to ensure that the specified algorithm ID is consistent with the type of signing key
 * supplied.
 * 
 * @param signingKey the key with which to compute the MAC
 * @param jcaAlgorithmID the Java JCA algorithm ID to use
 * @param input the input over which to compute the MAC
 * @return the computed MAC value
 * @throws SecurityException thrown if the MAC computation results in an error
 */
public static byte[] signMAC(Key signingKey, String jcaAlgorithmID, byte[] input) throws SecurityException {
    Logger log = getLogger();
    log.debug("Computing MAC over input using key of type {} and JCA algorithm ID {}", signingKey.getAlgorithm(),
            jcaAlgorithmID);

    try {
        Mac mac = Mac.getInstance(jcaAlgorithmID);
        mac.init(signingKey);
        mac.update(input);
        byte[] rawMAC = mac.doFinal();
        log.debug("Computed MAC: {}", new String(Hex.encode(rawMAC)));
        return rawMAC;
    } catch (GeneralSecurityException e) {
        log.error("Error during MAC generation", e);
        throw new SecurityException("Error during MAC generation", e);
    }
}
 
Example 5
Project: lams   File: Signer.java   View Source Code Vote up 6 votes
/**
 * Signs a single XMLObject.
 * 
 * @param signature the signature to computer the signature on
 * @throws SignatureException thrown if there is an error computing the signature
 */
public static void signObject(Signature signature) throws SignatureException {
    Logger log = getLogger();
    try {
        XMLSignature xmlSignature = ((SignatureImpl) signature).getXMLSignature();

        if (xmlSignature == null) {
            log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature "
                    + "created during marshalling.");
            throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature");
        }
        log.debug("Computing signature over XMLSignature object");
        xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential()));
    } catch (XMLSecurityException e) {
        log.error("An error occured computing the digital signature", e);
        throw new SignatureException("Signature computation error", e);
    }
}
 
Example 6
Project: orange-mathoms-logging   File: LoggingTest.java   View Source Code Vote up 5 votes
@Test
public void test_logging() {
	Logger logger = LoggerFactory.getLogger(LoggingTest.class);
	logger.info("info logging");
	try {
		new MyClient().getTheThings();
	} catch(Exception e) {
		logger.error("error logging with stack", e);
	}
}
 
Example 7
Project: servicebuilder   File: LogUtil.java   View Source Code Vote up 5 votes
public static void doLog(String s, LogLevel logLevel, Logger logger) {
    switch (logLevel) {
        case ERROR: {
            logger.error(s);
            break;
        }

        case WARN: {
            logger.warn(s);
            break;
        }

        case INFO: {
            logger.info(s);
            break;
        }

        case DEBUG: {
            logger.debug(s);
            break;
        }

        case TRACE: {
            logger.trace(s);
            break;
        }

        default: {
            logger.error(s);
            break;
        }
    }
}
 
Example 8
Project: QDrill   File: UserException.java   View Source Code Vote up 5 votes
/**
 * builds a user exception or returns the wrapped one. If the error is a system error, the error message is logged
 * to the given {@link Logger}.
 *
 * @param logger the logger to write to
 * @return user exception
 */
public UserException build(final Logger logger) {
  if (uex != null) {
    return uex;
  }

  boolean isSystemError = errorType == DrillPBError.ErrorType.SYSTEM;

  // make sure system errors use the root error message and display the root cause class name
  if (isSystemError) {
    message = ErrorHelper.getRootMessage(cause);
  }

  final UserException newException = new UserException(this);

  // since we just created a new exception, we should log it for later reference. If this is a system error, this is
  // an issue that the Drill admin should pay attention to and we should log as ERROR. However, if this is a user
  // mistake or data read issue, the system admin should not be concerned about these and thus we'll log this
  // as an INFO message.
  if (isSystemError) {
    logger.error(newException.getMessage(), newException);
  } else {
    logger.info("User Error Occurred", newException);
  }

  return newException;
}
 
Example 9
Project: openNaEF   File: VMEthernetPortBuilderFactory.java   View Source Code Vote up 5 votes
private void setBandwidth(PhysicalPortCommandBuilder builder, Enum<?> attr) {
    Logger log = LoggerFactory.getLogger(VMEthernetPortBuilderFactory.class);
    String speed = renderer.getValue(attr);
    if (speed != null) {
        try {
            long bandwidth = Long.parseLong(speed);
            builder.setBandwidth(bandwidth);
        } catch (NumberFormatException e) {
            log.error("cannot parse speed:[" + speed + "]", e);
        }
    }
}
 
Example 10
Project: openNaEF   File: PhysicalPortBuilderFactory.java   View Source Code Vote up 5 votes
private void setBandwidth(PhysicalPortCommandBuilder builder, Enum<?> attr) {
    Logger log = LoggerFactory.getLogger(PhysicalPortBuilderFactory.class);
    String speed = renderer.getValue(attr);
    if (speed == null) {
        return;
    }
    try {
        long bandwidth = Long.parseLong(speed);
        builder.setBandwidth(bandwidth);
    } catch (NumberFormatException e) {
        log.error("cannot parse speed:[" + speed + "]", e);
    }
}
 
Example 11
Project: lams   File: XMLObjectHelper.java   View Source Code Vote up 5 votes
/**
 * Unmarshall a Document from a Reader.
 * 
 * @param parserPool the ParserPool instance to use
 * @param reader the Reader to unmarshall
 * @return the unmarshalled XMLObject
 * @throws XMLParserException if there is a problem parsing the input data
 * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM
 */
public static XMLObject unmarshallFromReader(ParserPool parserPool, Reader reader)
        throws XMLParserException, UnmarshallingException {
    Logger log = getLogger();
    log.debug("Parsing Reader into DOM document");
    

    Document messageDoc = parserPool.parse(reader);
    Element messageElem = messageDoc.getDocumentElement();

    if (log.isTraceEnabled()) {
        log.trace("Resultant DOM message was:");
        log.trace(XMLHelper.nodeToString(messageElem));
    }

    log.debug("Unmarshalling DOM parsed from Reader");
    Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem);
    if (unmarshaller == null) {
        log.error("Unable to unmarshall Reader, no unmarshaller registered for element "
                + XMLHelper.getNodeQName(messageElem));
        throw new UnmarshallingException(
                "Unable to unmarshall Reader, no unmarshaller registered for element "
                        + XMLHelper.getNodeQName(messageElem));
    }

    XMLObject message = unmarshaller.unmarshall(messageElem);

    log.debug("Reader succesfully unmarshalled");
    return message;
}
 
Example 12
Project: lams   File: IPAddressHelper.java   View Source Code Vote up 5 votes
/**
 * Convert the byte array representation of an IP address into a string.  Supports IPv4 and IPv6 addresses.
 * Supports optional subnet mask stored within the same byte array.  If the latter is present, 
 * output will be: "ipAddr/mask".
 * 
 * @param address IP address in byte array form (in network byte order)
 * @return IP address as a string, or null if can not be processed
 */
public static String addressToString(byte[] address) {
    Logger log = getLogger();
    if (isIPv4(address)) {
        return ipv4ToString(address);
    } else if (isIPv6(address)) {
        return ipv6ToString(address);
    } else {
        log.error("IP address byte array was an invalid length: {}", address.length);
        return null;
    }
}
 
Example 13
Project: rocketmq-rocketmq-all-4.1.0-incubating   File: FilterServerUtil.java   View Source Code Vote up 5 votes
public static void callShell(final String shellString, final Logger log) {
    Process process = null;
    try {
        String[] cmdArray = splitShellString(shellString);
        process = Runtime.getRuntime().exec(cmdArray);
        process.waitFor();
        log.info("CallShell: <{}> OK", shellString);
    } catch (Throwable e) {
        log.error("CallShell: readLine IOException, {}", shellString, e);
    } finally {
        if (null != process)
            process.destroy();
    }
}
 
Example 14
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger,String format,Supplier<Object> supplier){
    if(logger.isErrorEnabled()){
        logger.error(format,supplier.get());
    }
}
 
Example 15
Project: lams   File: IPAddressHelper.java   View Source Code Vote up 4 votes
/**
 * Convert the byte array representation of an IPv6 address into a string.
 * Supports optional subnet mask stored within the same byte array.  If the latter is present, 
 * output will be: "ipAddr/mask".
 * 
 * @param address IP address in byte array form (in network byte order)
 * @return IP address as a string, or null if can not be processed
 */
private static String ipv6ToString(byte[] address) {
    Logger log = getLogger();
    // This code was modeled after similar code in Sun's sun.security.x509.IPAddressName,
    // used by sun.security.x509.X509CertImpl.
    StringBuilder builder = new StringBuilder();
    byte[] ip = new byte[16];
    System.arraycopy(address, 0, ip, 0, 16);
    try {
        builder.append(InetAddress.getByAddress(ip).getHostAddress());
    } catch (UnknownHostException e) {
        // Thrown if address is illegal length.
        // Can't happen, we know that address is the right length.
        log.error("Unknown host exception processing IP address byte array: {}", e.getMessage());
        return null;
    }
    
    if(hasMask(address)) {
        log.error("IPv6 subnet masks are currently unsupported");
        return null;
        /*
        byte[] mask = new byte[16];
        for(int i = 16; i < 32; i++) {
            mask[i - 16] = address[i];
        }
        
        // TODO need to process bitmask array
        // to determine and validate subnet mask
        BitArray bitarray = new BitArray(128, mask);
        int j;
        for (j = 0; j < 128 && bitarray.get(j); j++);
        builder.append("/");
        builder.append(j).toString();
        for (; j < 128; j++) {
            if (bitarray.get(j)) {
                log.error("Invalid IPv6 subdomain: set bit " + j + " not contiguous");
                return null;
            }
        }
        */
    }
    return builder.toString();
}
 
Example 16
Project: myth   File: LogUtil.java   View Source Code Vote up 4 votes
public static void error(Logger logger, String format, Supplier<Object> supplier) {
    if (logger.isErrorEnabled()) {
        logger.error(format, supplier.get());
    }
}
 
Example 17
Project: iTAP-controller   File: InstructionUtils.java   View Source Code Vote up 4 votes
/**
 * Convert the string representation of an OFInstructionMetadata to
 * an OFInstructionMetadata. The instruction will be set within the
 * OFFlowMod.Builder provided. Notice nothing is returned, but the
 * side effect is the addition of an instruction in the OFFlowMod.Builder.
 * @param fmb; The FMB in which to append the new instruction
 * @param instStr; The string to parse the instruction from
 * @param log
 */
public static void writeMetadataFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
	if (inst == null || inst.equals("")) {
		return;
	}

	if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
		log.error("Write Metadata Instruction not supported in OpenFlow 1.0");
		return;
	}

	OFInstructionWriteMetadata.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildWriteMetadata();

	// Process tokens (should be metadata or its mask)
	String[] keyValue = inst.split("/");	
	if (keyValue.length > 2) {
		throw new IllegalArgumentException("[Metadata, Mask] " + keyValue + " does not have form 'metadata/mask' or 'metadata' for parsing " + inst);
	} else if (keyValue.length == 1) {
		log.debug("No mask detected in OFInstructionWriteMetaData string.");
	} else if (keyValue.length == 2) {
		log.debug("Detected mask in OFInstructionWriteMetaData string.");
	}

	// Get the metadata
	if (keyValue[0].startsWith("0x")) {
		ib.setMetadata(U64.of(Long.valueOf(keyValue[0].replaceFirst("0x", ""), 16)));
	} else {
		ib.setMetadata(U64.of(Long.valueOf(keyValue[0])));
	}

	// Get the optional mask
	if (keyValue.length == 2) {
		if (keyValue[1].startsWith("0x")) {
			ib.setMetadataMask(U64.of(Long.valueOf(keyValue[1].replaceFirst("0x", ""), 16)));
		} else {
			ib.setMetadataMask(U64.of(Long.valueOf(keyValue[1])));
		}
	} else {
		ib.setMetadataMask(U64.NO_MASK);
	}

	log.debug("Appending WriteMetadata instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());
}
 
Example 18
Project: centraldogma   File: Polyfills.java   View Source Code Vote up 4 votes
public static void consoleError(Logger logger, ScriptObjectMirror args) {
    if (logger.isErrorEnabled()) {
        logger.error(logMessage(args));
    }
}
 
Example 19
Project: logback-logdna   File: LogDNATest.java   View Source Code Vote up 4 votes
/**
 * 
 * Signup for LogDNA then run the test like this to try it out.
 * 
 *    mvn test -DLOGDNA_INGEST_KEY="<my_logdna_ingest_key"
 */
@Test
public void testLogDNALogbackConf() throws InterruptedException
{
	MDC.put("customerId", "C-1");
	MDC.put("requestId", "cafebabe1");
	
    Logger logger = LoggerFactory.getLogger(LogDNATest.class);

    logger.info("Okay");
    
    logger.warn("Hmmm, that seemed odd...");
    
    logger.error("Ah Sh*t!", new RuntimeException("Bang!"));
    
    logger.info("Well, Bye!");
    
    Thread.sleep(2000);
}
 
Example 20
Project: Patterdale   File: HikariDataSourceProvider.java   View Source Code Vote up 4 votes
private static void logRetriesExceeded(DatabaseDefinition databaseDefinition, Logger logger) {
    logger.error(format("Exceeded retry attempts to database %s at %s.",
            databaseDefinition.name,
            databaseDefinition.jdbcUrl));
}