Example usage for java.util.logging Logger getResourceBundle

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

Introduction

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

Prototype

public ResourceBundle getResourceBundle() 

Source Link

Document

Retrieve the localization resource bundle for this logger.

Usage

From source file:fr.opensagres.xdocreport.core.logging.LogUtils.java

private static void doLog(Logger log, Level level, String msg, Throwable t) {
    LogRecord record = new LogRecord(level, msg);

    record.setLoggerName(log.getName());
    record.setResourceBundleName(log.getResourceBundleName());
    record.setResourceBundle(log.getResourceBundle());

    if (t != null) {
        record.setThrown(t);//from   w ww . ja va  2 s  . co m
    }

    // try to get the right class name/method name - just trace
    // back the stack till we get out of this class
    StackTraceElement stack[] = (new Throwable()).getStackTrace();
    String cname = LogUtils.class.getName();
    for (int x = 0; x < stack.length; x++) {
        StackTraceElement frame = stack[x];
        if (!frame.getClassName().equals(cname)) {
            record.setSourceClassName(frame.getClassName());
            record.setSourceMethodName(frame.getMethodName());
            break;
        }
    }
    log.log(record);
}

From source file:org.apache.cxf.common.logging.LogUtils.java

private static void doLog(Logger log, Level level, String msg, Throwable t) {
    LogRecord record = new LogRecord(level, msg);

    record.setLoggerName(log.getName());
    record.setResourceBundleName(log.getResourceBundleName());
    record.setResourceBundle(log.getResourceBundle());

    if (t != null) {
        record.setThrown(t);//from   w w w . j  av  a 2s .  co  m
    }

    //try to get the right class name/method name - just trace
    //back the stack till we get out of this class
    StackTraceElement stack[] = (new Throwable()).getStackTrace();
    String cname = LogUtils.class.getName();
    for (int x = 0; x < stack.length; x++) {
        StackTraceElement frame = stack[x];
        if (!frame.getClassName().equals(cname)) {
            record.setSourceClassName(frame.getClassName());
            record.setSourceMethodName(frame.getMethodName());
            break;
        }
    }
    log.log(record);
}

From source file:org.apache.cxf.common.logging.LogUtils.java

/**
 * Retrieve localized message retrieved from a logger's resource
 * bundle.// ww  w.  j av  a 2  s . c  o m
 *
 * @param logger the Logger
 * @param message the message to be localized
 */
private static String localize(Logger logger, String message) {
    ResourceBundle bundle = logger.getResourceBundle();
    try {
        return bundle != null ? bundle.getString(message) : message;
    } catch (MissingResourceException ex) {
        //string not in the bundle
        return message;
    }
}