Example usage for java.util.logging Logger severe

List of usage examples for java.util.logging Logger severe

Introduction

In this page you can find the example usage for java.util.logging Logger severe.

Prototype

public void severe(Supplier<String> msgSupplier) 

Source Link

Document

Log a SEVERE message, which is only to be constructed if the logging level is such that the message will actually be logged.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    Logger logger = Logger.getLogger("com.java2s.log");

    logger.severe("severe");
    logger.warning("warning");
    logger.info("info");
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("value =" + 42);
}

From source file:Logging.java

public static void main(String[] args) {
    Logger log = Logger.getLogger("global");

    log.finest("A");
    log.finer("B");
    log.fine("C");
    log.config("D");
    log.info("E");
    log.warning("O");
    log.severe("A");
}

From source file:MyHtmlFormatter.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger("com.mycompany");
    FileHandler fh = new FileHandler("mylog.html");
    fh.setFormatter(new MyHtmlFormatter());
    logger.addHandler(fh);/*  w ww.  j a  v a 2s .  co  m*/

    logger.setLevel(Level.ALL);
    logger.severe("my severe message");
    logger.info("my info message");
    logger.entering("Main class", "myMethod", new Object[] { "para1", "para2" });
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger("com.mycompany");
    FileHandler fh = new FileHandler("mylog.txt");
    fh.setFormatter(new SimpleFormatter());
    logger.addHandler(fh);// w w w.  j a v  a  2s . c o  m

    // fh = new FileHandler("mylog.xml");
    // fh.setFormatter(new XMLFormatter());
    // logger.addHandler(fh);

    // Log a few messages
    logger.severe("my severe message");
    logger.warning("my warning message");
    logger.info("my info message");
    logger.config("my config message");
    logger.fine("my fine message");
    logger.finer("my finer message");
    logger.finest("my finest message");
}

From source file:MainClass.java

public static void main(String args[]) {

    Logger logger = Logger.getLogger("my.log");

    Handler handler = null;//from w  w w  .  ja v  a 2 s. co  m

    try {
        handler = new FileHandler("messages.log");
    } catch (IOException e) {
        System.out.println("Could not create file. Using the console handler");
        handler = new ConsoleHandler();
    }

    logger.addHandler(handler);

    handler.setFormatter(new XMLFormatter());

    logger.info("Our first logging message");
    logger.severe("Something terrible happened");
}

From source file:net.roboconf.doc.generator.internal.GraphUtils.java

/**
 * Decodes an hexadecimal color and resolves it as an AWT color.
 * @param value the value to decode/*from  ww w .j  av a 2 s .co m*/
 * @param defaultValue the default value to use if value is invalid
 * @return a color (not null)
 */
static Color decode(String value, String defaultValue) {

    Color result;
    try {
        result = Color.decode(value);

    } catch (NumberFormatException e) {
        Logger logger = Logger.getLogger(GraphUtils.class.getName());
        logger.severe("The specified color " + value + " could not be parsed. Back to default value: "
                + defaultValue);
        Utils.logException(logger, e);
        result = Color.decode(defaultValue);
    }

    return result;
}

From source file:eu.wordnice.wnconsole.WNCUtils.java

/*** PROTECTED ***/
protected static Handler.OneVoidHandler<Logger> createOnDisable(final ServerSocket sock) {
    return new Handler.OneVoidHandler<Logger>() {
        @Override// ww w.  ja va2 s . co m
        public void handle(Logger lg) {
            try {
                sock.close();
                lg.info("WNConsole was disabled!");
            } catch (Throwable tr) {
                lg.severe("Ups, cannot close server service! Details:");
                tr.printStackTrace();
            }
        }
    };
}

From source file:com.google.apphosting.vmruntime.VmApiProxyDelegate.java

/**
 * Convert the RemoteApiPb.RpcError to the appropriate exception.
 *
 * @param rpcError the RemoteApiPb.RpcError.
 * @param packageName the name of the API package.
 * @param methodName the name of the method within the API package.
 * @param logger the Logger used to create log messages.
 * @return ApiProxyException/*from ww w .  j av  a  2 s . co m*/
 */
private static ApiProxyException convertApiResponseRpcErrorToException(RemoteApiPb.RpcError rpcError,
        String packageName, String methodName, Logger logger) {

    int rpcCode = rpcError.getCode();
    String errorDetail = rpcError.getDetail();
    if (rpcCode > RemoteApiPb.RpcError.ErrorCode.values().length) {
        logger.severe("Received unrecognized error code from server: " + rpcError.getCode() + " details: "
                + errorDetail);
        return new ApiProxy.UnknownException(packageName, methodName);
    }
    RemoteApiPb.RpcError.ErrorCode errorCode = RemoteApiPb.RpcError.ErrorCode.values()[rpcError.getCode()];
    logger.warning(
            "RPC failed, API=" + packageName + "." + methodName + " : " + errorCode + " : " + errorDetail);

    // This is very similar to apphosting/utils/runtime/ApiProxyUtils.java#convertApiError,
    // which is for APIResponse. TODO(user): retire both in favor of gRPC.
    switch (errorCode) {
    case CALL_NOT_FOUND:
        return new ApiProxy.CallNotFoundException(packageName, methodName);
    case PARSE_ERROR:
        return new ApiProxy.ArgumentException(packageName, methodName);
    case SECURITY_VIOLATION:
        logger.severe("Security violation: invalid request id used!");
        return new ApiProxy.UnknownException(packageName, methodName);
    case CAPABILITY_DISABLED:
        return new ApiProxy.CapabilityDisabledException(errorDetail, packageName, methodName);
    case OVER_QUOTA:
        return new ApiProxy.OverQuotaException(packageName, methodName);
    case REQUEST_TOO_LARGE:
        return new ApiProxy.RequestTooLargeException(packageName, methodName);
    case RESPONSE_TOO_LARGE:
        return new ApiProxy.ResponseTooLargeException(packageName, methodName);
    case BAD_REQUEST:
        return new ApiProxy.ArgumentException(packageName, methodName);
    case CANCELLED:
        return new ApiProxy.CancelledException(packageName, methodName);
    case FEATURE_DISABLED:
        return new ApiProxy.FeatureNotEnabledException(errorDetail, packageName, methodName);
    case DEADLINE_EXCEEDED:
        return new ApiProxy.ApiDeadlineExceededException(packageName, methodName);
    default:
        return new ApiProxy.UnknownException(packageName, methodName);
    }
}

From source file:edu.umass.cs.utils.Util.java

public static Object suicide(Logger logger, String error) {
    logger.severe(error);
    new RuntimeException(error).printStackTrace();
    System.exit(1);//from  w  w w.ja va  2s .com
    return null; // will never come here
}

From source file:net.roboconf.agent.internal.misc.UserDataUtils.java

/**
 * Configures the agent from Azure./* w  ww.  j av a 2 s  .c  om*/
 * @param logger a logger
 * @return the agent's data, or null if they could not be parsed
 */
public static AgentProperties findParametersForAzure(Logger logger) {

    String userData = "";
    try {
        // Get the user data from /var/lib/waagent/ovf-env.xml and decode it
        String userDataEncoded = getValueOfTagInXMLFile("/var/lib/waagent/ovf-env.xml", "CustomData");
        userData = new String(Base64.decodeBase64(userDataEncoded.getBytes("UTF-8")), "UTF-8");

    } catch (IOException | ParserConfigurationException | SAXException e) {
        logger.severe("The agent properties could not be read. " + e.getMessage());
        Utils.logException(logger, e);
    }

    // Get the public IP Address from /var/lib/waagent/SharedConfig.xml
    AgentProperties result = null;
    String publicIPAddress;
    try {
        result = AgentProperties.readIaasProperties(userData, logger);
        publicIPAddress = getSpecificAttributeOfTagInXMLFile("/var/lib/waagent/SharedConfig.xml", "Endpoint",
                "loadBalancedPublicAddress");
        result.setIpAddress(publicIPAddress);

    } catch (ParserConfigurationException | SAXException e) {
        logger.severe("The agent could not retrieve a public IP address. " + e.getMessage());
        Utils.logException(logger, e);

    } catch (IOException e) {
        logger.severe("The agent could not retrieve its configuration. " + e.getMessage());
        Utils.logException(logger, e);
    }

    return result;
}