LogRecord getParameters - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for LogRecord getParameters method.

This code example shows how to use the following methods:getLevel, getLoggerName, getMessage, getParameters, getThrown
     * juli handler that Redirect to log4j 
     */ 
    public static class JuliToLog4jHandler extends Handler {
 
        public void publish(LogRecord record) {
            org.apache.log4j.Logger log4j = getTargetLogger(record.getLoggerName());
            Priority priority = toLog4j(record.getLevel());
            log4j.log(priority, toLog4jMessage(record), record.getThrown());
        } 
 
        static org.apache.log4j.Logger getTargetLogger(String loggerName) {
            return org.apache.log4j.Logger.getLogger(loggerName);
        } 
 
        public static org.apache.log4j.Logger getTargetLogger(Class<?> clazz) {
            return getTargetLogger(clazz.getName());
        } 
 
        private String toLog4jMessage(LogRecord record) {
            String message = record.getMessage();

8
CodeRank
This code example shows how to use the following methods:getLevel, getLoggerName, getMessage, getParameters, getThrown
     * juli handler that Redirect to log4j 
     */ 
    public static class JuliToLog4jHandler extends Handler {
 
        public void publish(LogRecord record) {
            org.apache.log4j.Logger log4j = getTargetLogger(record.getLoggerName());
            Priority priority = toLog4j(record.getLevel());
            log4j.log(priority, toLog4jMessage(record), record.getThrown());
        } 
 
        static org.apache.log4j.Logger getTargetLogger(String loggerName) {
            return org.apache.log4j.Logger.getLogger(loggerName);
        } 
 
        public static org.apache.log4j.Logger getTargetLogger(Class<?> clazz) {
            return getTargetLogger(clazz.getName());
        } 
 
        private String toLog4jMessage(LogRecord record) {
            String message = record.getMessage();

7
CodeRank
This code example shows how to use the following methods:getLevel, getLoggerName, getMessage, getParameters, getResourceBundle
    public boolean isLoggable(final LogRecord record) {
        return true; 
    } 
 
    public void publish(final LogRecord record) {
        final String name = record.getLoggerName();
        Logger targetLogger = Logger.getLogger(name == null ? "anonymous" : name);
        final Priority targetLevel = levelMapper.getTargetLevelForSourceLevel(record.getLevel());
        final String text = formatRecord(record);
        targetLogger.log(LOGGER_CLASS_NAME, targetLevel, text, record.getThrown());
    } 
 
    private String formatRecord(final LogRecord record) {
        final ResourceBundle bundle = record.getResourceBundle();
        String msg = record.getMessage();
        if (bundle != null) {
            try { 
                msg = bundle.getString(msg);
            } catch (MissingResourceException ex) {
                // ignore 

6
CodeRank
This code example shows how to use the following methods:getLevel, getLoggerName, getParameters, getThrown
String msg = getMessage(record);
 
        try 
        { 
            Object params[] = record.getParameters();
            if ((params == null) || (params.length == 0))
            { 
                return msg;
            } 
 
            if (Pattern.compile("\\{\\d+\\}").matcher(msg).find())
            { 
                return MessageFormat.format(msg,params);
            } 
 
            return msg;
        } 
        catch (Exception ex)
        { 

7
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getMillis, getParameters, getSourceClassName
6
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getParameters, getThrown
        } 
    } 
 
    @Override 
    public void log(LogRecord record) {
        Level level = record.getLevel();
        String msg = record.getMessage();
        Object[] params = record.getParameters();
        Throwable thrown = record.getThrown();
 
        if (thrown != null) {
            log(level, msg, thrown);
        } else if (params != null) { 
            log(level, msg, params);
        } else { 
            log(level, msg);
        } 
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getParameters, getResourceBundle, getThrown
    lal.log(null, FQCN, slf4jLevel, i18nMessage, null, record.getThrown());
  } 
 
  protected void callPlainSLF4JLogger(Logger slf4jLogger, LogRecord record) {
    String i18nMessage = getMessageI18N(record);
    int julLevelValue = record.getLevel().intValue();
    if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
      slf4jLogger.trace(i18nMessage, record.getThrown());
    } else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
      slf4jLogger.debug(i18nMessage, record.getThrown());
    } else if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
      slf4jLogger.info(i18nMessage, record.getThrown());
    } else if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
      slf4jLogger.warn(i18nMessage, record.getThrown());
    } else { 
      slf4jLogger.error(i18nMessage, record.getThrown());
    } 
  } 
 
 

7
CodeRank
This code example shows how to use the following methods:getMessage, getParameters, getResourceBundle
    } 
 
    protected abstract void internalLogFormatted(String msg, LogRecord record);
 
    protected String formatMessage(LogRecord record) {
        String format = record.getMessage();
        ResourceBundle catalog = record.getResourceBundle();
        if (catalog != null) {
            try { 
                format = catalog.getString(record.getMessage());
            } catch (MissingResourceException ex) {
                format = record.getMessage();
            } 
        } 
        try { 
            Object parameters[] = record.getParameters();
            if (parameters == null || parameters.length == 0) { 
                return format;
            } 
            if (format.indexOf("{0") >= 0 || format.indexOf("{1") >= 0
                        || format.indexOf("{2") >= 0 || format.indexOf("{3") >= 0) {
6
CodeRank
This code example shows how to use the following methods:getLevel, getLoggerName, getMessage, getParameters, getThrown
 * Time: 3:31:21 PM 
 */ 
public class JuliToLog4jHandler extends Handler {
 
    public void publish(LogRecord record) {
        org.apache.log4j.Logger log4j = getTargetLogger(record.getLoggerName());
        Priority priority = toLog4j(record.getLevel());
        log4j.log(priority, toLog4jMessage(record), record.getThrown());
    } 
 
    static Logger getTargetLogger(String loggerName) {
        return Logger.getLogger(loggerName);
    } 
 
    public static Logger getTargetLogger(Class clazz) {
        return getTargetLogger(clazz.getName());
    } 
     
    private String toLog4jMessage(LogRecord record) {
        String message = record.getMessage();

6
CodeRank
This code example shows how to use the following methods:getParameters
    /* (non-Javadoc) 
     * @see java.util.logging.Formatter#format(java.util.logging.LogRecord) 
     */ 
    public String format(LogRecord lr) {
//        Throwable ex = lr.getThrown(); 
        Throwable ex = (Throwable)lr.getParameters()[1];
//        LocalizedError err = (LocalizedError) lr.getParameters()[1]; 
//        Throwable ex = (Throwable)err.exception; 
        StringWriter sw = new StringWriter();
        ex.printStackTrace(new PrintWriter(sw));
 
        return super.format(lr) + " " + sw.toString();
    } 
} 
 
 
6
CodeRank
getParameters Method Overview
Get the parameters to the log message.
See Code Examples for other Java 8 LogRecord Methods: