Package java.util.logging

Examples of java.util.logging.LogRecord


    public void testEventWithThrowable() {
        Exception e = new Exception();
        Monitor mon = factory.getMonitor(Monitor.class);
        mon.eventWithThrowable(e);
        assertEquals(1, handler.logs.size());
        LogRecord record = handler.logs.get(0);
        assertEquals(Level.WARNING, record.getLevel());
        assertEquals(logger.getName(), record.getLoggerName());
        assertEquals(Monitor.class.getName() + "#eventWithThrowable", record.getMessage());
        assertSame(e, record.getThrown());
    }
View Full Code Here


     */
    public void testEventWithOneArg() {
        Monitor mon = factory.getMonitor(Monitor.class);
        mon.eventWithOneArg("ARG");
        assertEquals(1, handler.logs.size());
        LogRecord record = handler.logs.get(0);
        assertEquals(Monitor.class.getName() + "#eventWithOneArg", record.getMessage());
    }
View Full Code Here

        }
       
    }

    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);
        }
       
        //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);
    }
View Full Code Here

   * @param msg
   * @param t
   */
  private void log(String callerFQCN, Level level, String msg, Throwable t) {
    // millis and thread are filled by the constructor
    LogRecord record = new LogRecord(level, msg);
    record.setLoggerName(getName());
    record.setThrown(t);
    fillCallerData(callerFQCN, record);
    logger.log(record);

  }
View Full Code Here

            log(level, message, null);
        }

        @Override
        public void log(Level level, String message, Throwable thrown) {
            LogRecord logRecord = new LogRecord(level, message);
            logRecord.setLoggerName(logger.getName());
            logRecord.setThrown(thrown);
            logRecord.setSourceClassName(logger.getName());
            logger.log(logRecord);
        }
View Full Code Here

            }
            boolean loggable = logger.isLoggable(level);
            if (loggable || level.intValue() >= minLevel.intValue()) {
                String logRecordMessage = thisAddressString + " [" + groupName + "] "
                        + "[" + buildInfo.getVersion() + "] " + message;
                LogRecord logRecord = new LogRecord(level, logRecordMessage);
                logRecord.setThrown(thrown);
                logRecord.setLoggerName(name);
                logRecord.setSourceClassName(name);
                LogEvent logEvent = new LogEvent(logRecord, groupName, thisMember);
                if (loggable) {
                    logger.log(logEvent);
                }
                if (listeners.size() > 0) {
View Full Code Here

            return handler;
        }

        @Override
        protected void append(LoggingEvent event) {
            LogRecord lr = new LogRecord(fromL4J(event.getLevel()),
                                         event.getMessage().toString());
            lr.setLoggerName(event.getLoggerName());
            if (event.getThrowableInformation() != null) {
                lr.setThrown(event.getThrowableInformation().getThrowable());
            }
            String rbname = getResourceBundleName();
            if (rbname != null) {
                lr.setResourceBundleName(rbname);
                lr.setResourceBundle(getResourceBundle());
            }
            getFullInfoForLogUtils(lr, event.fqnOfCategoryClass);
            handler.publish(lr);
        }
View Full Code Here

        }
    }

    public void log(Level level, String msg) {
        if (isLoggable(level)) {
            LogRecord lr = new LogRecord(level, msg);
            doLog(lr);
        }
    }
View Full Code Here

        }
    }

    public void log(Level level, String msg, Object param1) {
        if (isLoggable(level)) {
            LogRecord lr = new LogRecord(level, msg);
            Object params[] = {param1 };
            lr.setParameters(params);
            doLog(lr);
        }
    }
View Full Code Here

        }
    }

    public void log(Level level, String msg, Object params[]) {
        if (isLoggable(level)) {
            LogRecord lr = new LogRecord(level, msg);
            lr.setParameters(params);
            doLog(lr);
        }
    }
View Full Code Here

TOP

Related Classes of java.util.logging.LogRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.