Package java.util.logging

Examples of java.util.logging.LogRecord


     * @param  level the level at which to log
     * @param  message the log message, which can be <code>null</code>
     */
    public void log(Level level, String message) {
  if (logger.isLoggable(level)) {
      log(new LogRecord(level, message));
  }
    }
View Full Code Here


     * @param  param the parameter value for the log message, which can be
     *     <code>null</code>
     */
    public void log(Level level, String message, Object param) {
  if (logger.isLoggable(level)) {
      LogRecord lr = new LogRecord(level, message);
      lr.setParameters(new Object[]{ param });
      log(lr);
  }
    }
View Full Code Here

     * @param  params the parameter values for the log message, which can be
     *     <code>null</code>
     */
    public void log(Level level, String message, Object... params) {
  if (logger.isLoggable(level)) {
      LogRecord lr = new LogRecord(level, message);
      lr.setParameters(params);
      log(lr);
  }
    }
View Full Code Here

     *     message
     * @param  message the log message, which can be <code>null</code>
     */
    public void logThrow(Level level, Throwable thrown, String message) {
  if (logger.isLoggable(level)) {
      LogRecord lr = new LogRecord(level, message);
      lr.setThrown(thrown);
      log(lr);
  }
    }
View Full Code Here

       Throwable thrown,
       String message,
       Object param)
    {
  if (logger.isLoggable(level)) {
      LogRecord lr = new LogRecord(level, message);
      lr.setThrown(thrown);
      lr.setParameters(new Object[]{ param });
      log(lr);
  }
    }
View Full Code Here

       Throwable thrown,
       String message,
       Object... params)
    {
  if (logger.isLoggable(level)) {
      LogRecord lr = new LogRecord(level, message);
      lr.setThrown(thrown);
      lr.setParameters(params);
      log(lr);
  }
    }
View Full Code Here

        try {
            while(!done) {
                try {
                    Object msg = in.readObject();
                    if (msg instanceof LogRecord) {
                        LogRecord logR = (LogRecord)msg;
                        logR.setLoggerName("slave"+slaveID+":"+logR.getLoggerName());
                        logger.log(logR);
                    } else if (msg instanceof TestReply) {
                        System.err.println("GOT REPLY "+msg);
                        for(TestReplyListener l : replyListeners)
                            l.received((TestReply)msg);
View Full Code Here

public class JavaLoggingFormatterTest {

    /** Test the LogInfo class. */
    @Test public void testLogInfo() {
        Date now = DateUtils.createDate(2011, 10, 7, 13, 1, 42, 663);
        LogRecord record = mock(LogRecord.class);
        when(record.getMillis()).thenReturn(now.getTime());
        when(record.getLevel()).thenReturn(java.util.logging.Level.INFO);
        when(record.getSourceClassName()).thenReturn("test.class.Name");
        when(record.getMessage()).thenReturn("message");

        LogInfo info = new LogInfo(record);
        assertNotNull(info);
        assertEquals(now, info.getDate());
        assertEquals(org.apache.log4j.Level.INFO, info.getLevel());
View Full Code Here

                                                                       org.apache.log4j.Level.DEBUG,
                                                                       org.apache.log4j.Level.TRACE,
                                                                       org.apache.log4j.Level.ALL, };

        for (int i = 0; i < input.length; i++) {
            LogRecord record = mock(LogRecord.class);
            when(record.getLevel()).thenReturn(input[i]);
            LogInfo info = new LogInfo(record);
            assertEquals(output[i], info.getLevel());
        }
    }
View Full Code Here

    public void fatal(Object o, Throwable t) {
        logger.log(record(o, t, Level.SEVERE));
    }

    private LogRecord record(final Object o, final Throwable t, final Level level) {
        final LogRecord record = record(o, level);
        record.setThrown(t);
        return record;
    }
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.