LogRecord getMillis - 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 getMillis method.

This code example shows how to use the following methods:getLevel, getLoggerName, getMillis, getThreadID, getThrown
   * @return a formatted log record 
   */ 
  @Override 
  public synchronized String format(final LogRecord record) {
    buffer.setLength(PREFIX.length());
    buffer.append(timestampFormatter.format(new Date(record.getMillis())));
    buffer.append(' ');
    buffer.append(levelNumberToCommonsLevelName(record.getLevel()));
    if (longForm) {
      buffer.append(" [");
      buffer.append(record.getThreadID());
      buffer.append("] ");
      buffer.append(record.getLoggerName());
    } 
    buffer.append(SUFFIX);
    buffer.append(formatMessage(record)).append('\n');
    if (record.getThrown() != null) {
      final StringWriter trace = new StringWriter();
      record.getThrown().printStackTrace(new PrintWriter(trace));
      buffer.append(trace);

8
CodeRank
This code example shows how to use the following methods:getLevel, getLoggerName, getMillis, getThrown
    // MCPC+ end 
 
    public String format(LogRecord record)
    { 
        StringBuilder msg = new StringBuilder();
        msg.append(this.dateFormat.format(Long.valueOf(record.getMillis())));
        Level lvl = record.getLevel();
 
        String name = lvl.getLocalizedName();
        if ( name == null )
        { 
            name = lvl.getName();        	
        } 
 
        if ( ( name != null ) && ( name.length() > 0 ) )
        { 
            msg.append(" [" + name + "] ");
        } 
        else 
        { 

8
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getMillis, getSourceClassName, getThrown
 
public class LoggerShortFormat extends java.util.logging.Formatter {
  @Override 
  @Nonnull 
  public String format(@Nonnull final LogRecord record) {
    return record.getMillis() + " " +
        record.getLevel() + " [" +
        record.getSourceClassName() + "] " +
        record.getMessage() +
        (record.getThrown() != null ? " Stack trace:\n" + getStackTrace(record.getThrown()) : "") + "\n";
  } 
 
  public static void intialize() throws Exception { 
    InputStream input = null;
    try { 
      input = LoggerShortFormat.class.getClassLoader().getResourceAsStream("logging.properties");
      LogManager.getLogManager().readConfiguration(input);
    } finally { 
      if (input != null) {
        input.close();
8
CodeRank
This code example shows how to use the following methods:getLevel, getMillis, getThrown
This code example shows how to use the following methods:getLevel, getMillis, getSourceClassName, getSourceMethodName
    // Create a StringBuffer to contain the formatted record 
    // start with the date. 
    StringBuffer sb = new StringBuffer();
 
    // Get the date from the LogRecord and add it to the buffer 
    Date date = new Date(record.getMillis());
    sb.append(datef.format(date));
    sb.append(" ");
 
    // Get the level name and add it to the buffer 
    sb.append(record.getLevel().getName());
    sb.append(" ");
 
    String[] pieces = record.getSourceClassName().split("\\.");
    String name = pieces[pieces.length - 1];
    sb.append(name);
    sb.append(".");
    sb.append(record.getSourceMethodName());
    sb.append("  ");
 

7
CodeRank
This code example shows how to use the following methods:getLevel, getMillis, getSourceClassName, getSourceMethodName, getThreadID
This code example shows how to use the following methods:getLevel, getMillis, getSequenceNumber, getSourceClassName, getSourceMethodName
		StringBuffer buf = new StringBuffer(1000);
		// Bold any levels >= WARNING 
		buf.append("<tr>");
		buf.append("<td>");
 
		if (rec.getLevel().intValue() >= Level.WARNING.intValue())
		{ 
			buf.append("<b>");
			buf.append(rec.getLevel().getName());
			buf.append("</b>");
		} else 
		{ 
			buf.append(rec.getLevel().getName());
		} 
		buf.append("</td>");
		buf.append("<td>");
		buf.append(calcDate(rec.getMillis()));
		buf.append("</td>");
		buf.append("<td>");
		buf.append(formatMessage(rec));

7
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getMillis, getSequenceNumber, getSourceClassName
	 * @see java.util.logging.Handler#publish(java.util.logging.LogRecord) 
	 */ 
	@Override 
	public void publish(LogRecord record) {
		TestLogs testLogs = new TestLogs();		
		testLogs.setLogLevel(record.getLevel().getName());
		testLogs.setLogTime(new Date(record.getMillis()));
		testLogs.setMessage(record.getMessage());
		testLogs.setSequenceNumber(record.getSequenceNumber());
		testLogs.setClassName(record.getSourceClassName());
		testLogs.setMethodName(record.getSourceMethodName());
		testLogs.setThrowable(ClientCommon.toString(record.getThrown()));
		try { 
			remoteApi.insertLogMessage(testLogs);
		} catch (Exception ex) {
			LogHandler.teardown(); 
			System.out.println("error writing log to report engine; removing appender;");
			ex.printStackTrace();
		} 
	} 
6
CodeRank
This code example shows how to use the following methods:getMessage, getMillis, getSourceClassName, getSourceMethodName, getThreadID
This code example shows how to use the following methods:getLevel, getMillis, getSourceClassName, getSourceMethodName, getThreadID
 
    if (threadFormat == null)
      threadFormat = new DecimalFormat(THREAD_PATTERN);
 
    StringBuilder sb = new StringBuilder(180)
        .append(dateFormat.format(new Date(record.getMillis())))
        .append(threadFormat.format(record.getThreadID()))
        .append(" ");
    String s = record.getSourceClassName();
    if (s == null)
      sb.append(SPACES_32);
    else 
      { 
        s = s.trim();
        int i = s.lastIndexOf(".");
        if (i != - 1)
          s = s.substring(i + 1);
 
        s = (s + SPACES_32).substring(0, 32);
      } 

6
CodeRank
getMillis Method Overview
Get event time in milliseconds since 1970.
See Code Examples for other Java 8 LogRecord Methods: