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

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, getLoggerName, getMessage, getResourceBundle, getSequenceNumber
        check(logger.isLoggable(Level.WARNING));
        logger.addHandler(new Handler() {
            public void close() {} 
            public void flush() {} 
            public void publish(LogRecord l) {
                equal(l.getLoggerName(), name);
                equal(l.getMessage(), message);
                equal(l.getResourceBundle(), null);
                equal(l.getSourceClassName(), "LoggerSubclass");
                equal(l.getSourceMethodName(), "test");
                equal(l.getThrown(), null);
                equal(l.getLevel(), Level.WARNING);
 
                if (lastSequenceNumber.get() != -1) {
                    equal(lastSequenceNumber.get() + 1,
                          l.getSequenceNumber());
                    equal(lastThreadID.get(),
                          l.getThreadID());
                    equal((int) Thread.currentThread().getId(),
                          l.getThreadID());

7
CodeRank
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, getMessage, getSourceClassName, getSourceMethodName
import java.util.logging.LogRecord; 
 
public class ShortFormatter extends Formatter {
  // inefficient implementation 
  public String format(LogRecord record) {
    return record.getLevel() + " [" + record.getSourceClassName() + ":"
        + record.getSourceMethodName() + "] " + record.getMessage() + "\n";
  } 
} 
6
CodeRank
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
This code example shows how to use the following methods:getLevel, getLoggerName, getMillis, getSourceClassName, getSourceMethodName
    public synchronized String format(final LogRecord record) {
        /* clear StringBuilder buffer */ 
        final StringBuilder sb = new StringBuilder();
 
        // Minimize memory allocations here. 
        this.date.setTime(record.getMillis());
 
        final String message = this.formatMessage(record);
        final int th = record.getThreadID();
 
        // new Thread. 
        if (th != this.lastThreadID) {
            sb.append("\r\n THREAD: ");
            sb.append(th);
            sb.append("\r\n");
        } 
        this.lastThreadID = th;
 
        sb.append(record.getThreadID());
        sb.append('|');

6
CodeRank
This code example shows how to use the following methods:getLevel, getMessage, getMillis, getSourceClassName, getSourceMethodName
 
        // Create a StringBuilder to contain the formatted record 
        // start with the date. 
        StringBuilder builder = new StringBuilder();
 
        builder.append(df.format(new Date(record.getMillis()))).append(" - [");
        builder.append(record.getSourceClassName()).append('.');
        builder.append(record.getSourceMethodName()).append("] - [");
        builder.append(record.getLevel()).append("] - ");
        builder.append(record.getMessage());
 
        Throwable thrown = record.getThrown();
        if (thrown != null) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            thrown.printStackTrace(pw);
 
            builder.append(" StackTrace:");
            builder.append(sw.toString());
        } 
6
CodeRank
getSourceMethodName Method Overview
Get the name of the method that (allegedly) issued the logging request.
See Code Examples for other Java 8 LogRecord Methods: