當前位置: 首頁>>代碼示例>>Java>>正文


Java LogRecord.getLoggerName方法代碼示例

本文整理匯總了Java中java.util.logging.LogRecord.getLoggerName方法的典型用法代碼示例。如果您正苦於以下問題:Java LogRecord.getLoggerName方法的具體用法?Java LogRecord.getLoggerName怎麽用?Java LogRecord.getLoggerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.logging.LogRecord的用法示例。


在下文中一共展示了LogRecord.getLoggerName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isLoggable

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public boolean isLoggable(LogRecord record)
{
	if (record.getLoggerName() != "item") return false;
	if (_excludeProcess != null)
	{
		//if (record.getMessage() == null) return true;
		String[] messageList = record.getMessage().split(":");
		if (messageList.length < 2 || !_excludeProcess.contains(messageList[1])) return true;
	}
	if (_excludeItemType != null)
	{
		//if (record.getParameters() == null || record.getParameters().length == 0 || !(record.getParameters()[0] instanceof L2ItemInstance)) return true;
		L2ItemInstance item = ((L2ItemInstance)record.getParameters()[0]);
		if (!_excludeItemType.contains(item.getItemType().toString())) return true;
	}
	return (_excludeProcess == null && _excludeItemType == null);
}
 
開發者ID:L2jBrasil,項目名稱:L2jBrasil,代碼行數:18,代碼來源:ItemFilter.java

示例2: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    if (!isLoggable(record)) {
        return;
    }
    int severity = IStatus.INFO;
    if (record.getLevel() == Level.SEVERE) {
        severity = IStatus.ERROR;
    } else if (record.getLevel() == Level.WARNING) {
        severity = IStatus.WARNING;
    }

    IStatus status = new Status(severity, record.getLoggerName(), record.getMessage(), record.getThrown());

    Platform.getLog(JavaDebuggerServerPlugin.context.getBundle()).log(status);
}
 
開發者ID:Microsoft,項目名稱:java-debug,代碼行數:17,代碼來源:JdtLogHandler.java

示例3: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    if (isOn && record.getLoggerName() != null) {
        synchronized (earlyRecords) {
            earlyRecords.add(record);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:EarlyHandler.java

示例4: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public synchronized String format(LogRecord record) {

		final String sourceClassName = record.getSourceClassName();
		final String sourceMethodName = record.getSourceMethodName();

		mCalendar.setTimeInMillis(record.getMillis());

		final StringBuilder sb = new StringBuilder();
		sb.append(String.format("%1$tD %1$tT.%1$tL [%2$6s] ", mCalendar, record.getLevel().toString()));

		if (sourceClassName != null) {
			sb.append(sourceClassName);
		} else {
			String loggerName = record.getLoggerName();
			sb.append(loggerName);
		}
		sb.append(" ");

		if (sourceMethodName != null) {
			sb.append(String.format("#%s", sourceMethodName));
		}
		sb.append(" ");
		sb.append(formatMessage(record));
		sb.append("\n");
		Throwable thrown = record.getThrown();
		if (thrown != null) {
			sb.append(record.getThrown());
		}
		return sb.toString();
	}
 
開發者ID:riversun,項目名稱:java-firebase-fcm-client,代碼行數:31,代碼來源:LogFormatter.java

示例5: buildParameters

import java.util.logging.LogRecord; //導入方法依賴的package包/類
private Object[] buildParameters(LogRecord record) {
    StackTraceElement frame = getCaller();

    Object[] arguments = new Object[otherPartsSize + 1];
    arguments[0] = new Long(record.getSequenceNumber());
    arguments[1] = new Date(record.getMillis());
    arguments[2] = record.getLoggerName();
    arguments[3] = record.getSourceClassName();
    arguments[4] = record.getSourceMethodName();
    if (frame != null) {
        arguments[5] = frame.getFileName();
        arguments[6] = frame.getLineNumber();
    } else {
        arguments[5] = "";
        arguments[6] = -1;
    }
    // LogRecord.getThreadID is not the actual thread ID.
    // arguments[7]=new Integer(record.getThreadID());
    arguments[7] = Thread.currentThread().getId();
    arguments[12] = Thread.currentThread().getName();

    // arguments[8]=record.getLevel().getLocalizedName();
    // this is faster, but not i18n
    arguments[8] = record.getLevel().getName();
    arguments[9] = new Integer(record.getLevel().intValue());
    arguments[11] = writeThrowable(arguments, record, 0);
    return arguments;
}
 
開發者ID:Hitachi-Data-Systems,項目名稱:Open-DM,代碼行數:29,代碼來源:DefaultFormatter.java

示例6: asSerializableLogRecord

import java.util.logging.LogRecord; //導入方法依賴的package包/類
private SerializableLogRecord asSerializableLogRecord(LogRecord record) {
    SerializableLogRecord serializableLogRecord = new SerializableLogRecord();
    serializableLogRecord.level = record.getLevel().toString();
    serializableLogRecord.millis = record.getMillis();
    serializableLogRecord.message = record.getMessage();
    serializableLogRecord.loggerName = record.getLoggerName();
    serializableLogRecord.permutationStrongName = GWT.getPermutationStrongName();
    serializableLogRecord.thrown = serializableThrowable(unwrap(record.getThrown()));
    return serializableLogRecord;
}
 
開發者ID:GwtDomino,項目名稱:domino,代碼行數:11,代碼來源:RestfulRemoteLogHandler.java

示例7: getAgName

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public static String getAgName(LogRecord l) {
    String lname = l.getLoggerName();
    int posd = lname.lastIndexOf('.');
    if (posd > 0) {
        return lname.substring(posd+1);
    }
    return lname;
}
 
開發者ID:nickrfer,項目名稱:code-sentinel,代碼行數:9,代碼來源:MASConsoleLogFormatter.java

示例8: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public final String format(final LogRecord record) {
    final StringBuffer sb = new StringBuffer();

    date.setTime(record.getMillis());

    sb.append(sfDateOut.format(date));

    String recordName;

    if (record.getSourceClassName() != null) {
        recordName = record.getSourceClassName() + ":" + record.getSourceMethodName();
    } else {
        recordName = record.getLoggerName() + ":";
    }
    if (recordName != null) {
        sb.append(recordName);
        sb.append(":");
    }
    final String message = formatMessage(record);
    sb.append(record.getLevel().getLocalizedName());
    sb.append(": ");
    sb.append(message);
    sb.append(lineSeparator);

    if (record.getThrown() != null) {
        try {
            final StringWriter sw = new StringWriter();
            final PrintWriter pw = new PrintWriter(sw);
            record.getThrown().printStackTrace(pw);
            pw.close();
            sb.append(sw.toString());
        } catch (Exception ex) {
        }
    }
    return sb.toString();
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:37,代碼來源:LogFormatter.java

示例9: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
 * Format the given LogRecord.
 * @param record the log record to be formatted.
 * @return a formatted log record
 */
@Override
public synchronized String format(LogRecord record)
{
    date.setTime(record.getMillis());
    StringBuffer sb = new StringBuffer(dformat.format(date));
    if (record.getLoggerName() != null)
        sb.append(" " + record.getLoggerName());
    if (record.getSourceMethodName() != null)
        sb.append(" " + record.getSourceMethodName());
    sb.append(" " + record.getLevel().getLocalizedName() + ": ");
    sb.append(formatMessage(record).replaceAll("[\b]", ""));
    sb.append("\n");

    if (record.getThrown() != null)
    {
        try
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            record.getThrown().printStackTrace(pw);
            pw.close();
            sb.append(sw.toString());
        }
        catch (Exception ex)
        {
        }
    }

    return sb.toString();
}
 
開發者ID:drytoastman,項目名稱:scorekeeperfrontend,代碼行數:36,代碼來源:AppSetup.java

示例10: isLoggable

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public boolean isLoggable(LogRecord record)
{
	return record.getLoggerName() == "chat";
}
 
開發者ID:L2jBrasil,項目名稱:L2jBrasil,代碼行數:5,代碼來源:ChatFilter.java

示例11: getPackageLogger

import java.util.logging.LogRecord; //導入方法依賴的package包/類
private Logger getPackageLogger() {
      if (logger == null) {
          String prop = System.getProperty(packageName, DEFAULT_NAME);
          for (int i = 1; i < LEVELS.length; i++) {
              if (prop.toLowerCase().equals(LEVEL_NAMES[i].toLowerCase())) {
                  level = LEVELS[i];
                  break;
              }
          }
          LogManager.getLogManager().addLogger(new Logger(packageName, null)
{});
          logger = LogManager.getLogManager().getLogger(packageName);
          if (logger == null) {
              System.out.println(packageName + ": "
		   + rb.getString("CANT_GET_LOGGER"));
              return Logger.getLogger("global");
          }
          try {
              logger.setLevel(level);
              Handler handler = new ConsoleHandler();
              handler.setLevel(level);
// Default handlers don't provide class name or method name, so roll our own
logger.setUseParentHandlers(false);
Formatter formatter = new Formatter() {
	public String format(LogRecord record) {
	    StringBuffer s = new StringBuffer();
	    s.append(record.getLevel().getLocalizedName());
	    s.append(' ');
	    if (record.getLoggerName() != null) {
		s.append('[');
		s.append(record.getLoggerName());
		s.append("]: ");
	    }
	    if (record.getSourceClassName() != null) {
		s.append("| ");
		if (record.getLevel().equals(Level.FINEST)) {
		    String className = record.getSourceClassName();
		    s.append(className.substring(Math.max(className.lastIndexOf('.')+1,0)));
		} else {
		    s.append(record.getSourceClassName());
		}
		s.append(' ');
	    }
	    if (record.getSourceMethodName() != null) {
		s.append("|  ");
		s.append(record.getSourceMethodName());
		s.append("( ");
		Object[] parms = record.getParameters();
		if (parms != null) {
		    for (int i = 0; i < parms.length; i++) {
			if (i != 0) {
			    s.append(", ");
			}
			s.append(parms[i]);
		    }
		}
		s.append(" ) ");
	    }
	    if (record.getThrown() != null) {
		s.append("| ");
		s.append(record.getThrown());
	    }
	    if (record.getMessage() != null) {
		s.append('|');
		s.append(record.getMessage());
	    }
	    s.append('\n');
	    return s.toString();
	}
                  };
              handler.setFormatter(formatter);
              logger.addHandler(handler);
          }
          catch (SecurityException e) {
          }
      }

      return logger;
  }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:80,代碼來源:Log.java

示例12: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record) {
    Throwable t=record.getThrown();
    int level=record.getLevel().intValue();
    String name=record.getLoggerName();
    long time=record.getMillis();
    String message=formatMessage(record);


    if( name.indexOf('.') >= 0 )
        name = name.substring(name.lastIndexOf('.') + 1);

    // Use a string buffer for better performance
    StringBuilder buf = new StringBuilder();
    
    buf.append(time);
    
    // pad to 8 to make it more readable 
    for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
    
    //      Append a readable representation of the log level.
    switch(level) {
     case LOG_LEVEL_TRACE: buf.append(" T "); break;
     case LOG_LEVEL_DEBUG: buf.append(" D "); break;
     case LOG_LEVEL_INFO:  buf.append(" I ");  break;
     case LOG_LEVEL_WARN:  buf.append(" W ");  break;
     case LOG_LEVEL_ERROR: buf.append(" E "); break;
     //case : buf.append(" F "); break;
     default: buf.append("   ");
     }
     

    // Append the name of the log instance if so configured
    buf.append(name);
    buf.append(" ");

    // pad to 20 chars 
    for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
            
    // Append the message
    buf.append(message);
    
    // Append stack trace if not null
    if(t != null) {
        buf.append(LINE_SEP);
        
        java.io.StringWriter sw= new java.io.StringWriter(1024);
        java.io.PrintWriter pw= new java.io.PrintWriter(sw);
        t.printStackTrace(pw);
        pw.close();
        buf.append(sw.toString());
    }
    
    buf.append(LINE_SEP);
    // Print to the appropriate destination
    return buf.toString();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:58,代碼來源:JdkLoggerFormatter.java

示例13: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public String format(LogRecord record) {
    Throwable t=record.getThrown();
    int level=record.getLevel().intValue();
    String name=record.getLoggerName();
    long time=record.getMillis();
    String message=formatMessage(record);

    
    if( name.indexOf(".") >= 0 ) 
        name = name.substring(name.lastIndexOf(".") + 1);

    // Use a string buffer for better performance
    StringBuffer buf = new StringBuffer();
    
    buf.append(time);
    buf.append(" ");
    
    // pad to 8 to make it more readable 
    for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
    
    //      Append a readable representation of the log level.
    switch(level) {
     case LOG_LEVEL_TRACE: buf.append(" T "); break;
     case LOG_LEVEL_DEBUG: buf.append(" D "); break;
     case LOG_LEVEL_INFO:  buf.append(" I ");  break;
     case LOG_LEVEL_WARN:  buf.append(" W ");  break;
     case LOG_LEVEL_ERROR: buf.append(" E "); break;
     //case : buf.append(" F "); break;
     default: buf.append("   ");
     }
     

    // Append the name of the log instance if so configured
    buf.append(name);
    
    // pad to 20 chars 
    for( int i=0; i<8-buf.length(); i++ ) { buf.append(" "); }
            
    // Append the message
    buf.append(message);
    
    // Append stack trace if not null
    if(t != null) {
        buf.append(" \n");
        
        java.io.StringWriter sw= new java.io.StringWriter(1024);
        java.io.PrintWriter pw= new java.io.PrintWriter(sw);
        t.printStackTrace(pw);
        pw.close();
        buf.append(sw.toString());
    }
    
    buf.append("\n");
    // Print to the appropriate destination
    return buf.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:57,代碼來源:JdkLoggerFormatter.java

示例14: getLoggerName

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String getLoggerName(LogRecord res) {
    return res.getLoggerName();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:LoggerFinderBackendTest.java

示例15: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord record) {
	Throwable t = record.getThrown();
	int level = record.getLevel().intValue();
	String name = record.getLoggerName();
	long time = record.getMillis();
	String message = formatMessage(record);

	if (name.indexOf('.') >= 0)
		name = name.substring(name.lastIndexOf('.') + 1);

	// Use a string buffer for better performance
	StringBuilder buf = new StringBuilder();

	buf.append(time);

	// pad to 8 to make it more readable
	for (int i = 0; i < 8 - buf.length(); i++) {
		buf.append(" ");
	}

	// Append a readable representation of the log level.
	switch (level) {
	case LOG_LEVEL_TRACE:
		buf.append(" T ");
		break;
	case LOG_LEVEL_DEBUG:
		buf.append(" D ");
		break;
	case LOG_LEVEL_INFO:
		buf.append(" I ");
		break;
	case LOG_LEVEL_WARN:
		buf.append(" W ");
		break;
	case LOG_LEVEL_ERROR:
		buf.append(" E ");
		break;
	// case : buf.append(" F "); break;
	default:
		buf.append("   ");
	}

	// Append the name of the log instance if so configured
	buf.append(name);
	buf.append(" ");

	// pad to 20 chars
	for (int i = 0; i < 8 - buf.length(); i++) {
		buf.append(" ");
	}

	// Append the message
	buf.append(message);

	// Append stack trace if not null
	if (t != null) {
		buf.append(LINE_SEP);

		java.io.StringWriter sw = new java.io.StringWriter(1024);
		java.io.PrintWriter pw = new java.io.PrintWriter(sw);
		t.printStackTrace(pw);
		pw.close();
		buf.append(sw.toString());
	}

	buf.append(LINE_SEP);
	// Print to the appropriate destination
	return buf.toString();
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:71,代碼來源:JdkLoggerFormatter.java


注:本文中的java.util.logging.LogRecord.getLoggerName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。