本文整理匯總了Java中org.slf4j.Logger.error方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.error方法的具體用法?Java Logger.error怎麽用?Java Logger.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.slf4j.Logger
的用法示例。
在下文中一共展示了Logger.error方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: meterFromString
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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());
}
示例2: validateNonSunJAXP
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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);
}
}
示例3: ClassDetails
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
示例4: signMAC
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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);
}
}
示例5: signObject
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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);
}
}
示例6: test_logging
import org.slf4j.Logger; //導入方法依賴的package包/類
@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);
}
}
示例7: doLog
import org.slf4j.Logger; //導入方法依賴的package包/類
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;
}
}
}
示例8: build
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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;
}
示例9: setBandwidth
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
}
示例10: setBandwidth
import org.slf4j.Logger; //導入方法依賴的package包/類
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);
}
}
示例11: unmarshallFromReader
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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;
}
示例12: addressToString
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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;
}
}
示例13: callShell
import org.slf4j.Logger; //導入方法依賴的package包/類
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();
}
}
示例14: error
import org.slf4j.Logger; //導入方法依賴的package包/類
public static void error(Logger logger,String format,Supplier<Object> supplier){
if(logger.isErrorEnabled()){
logger.error(format,supplier.get());
}
}
示例15: ipv6ToString
import org.slf4j.Logger; //導入方法依賴的package包/類
/**
* 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();
}