本文整理匯總了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);
}
示例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);
}
示例3: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
if (isOn && record.getLoggerName() != null) {
synchronized (earlyRecords) {
earlyRecords.add(record);
}
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例10: isLoggable
import java.util.logging.LogRecord; //導入方法依賴的package包/類
public boolean isLoggable(LogRecord record)
{
return record.getLoggerName() == "chat";
}
示例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;
}
示例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();
}
示例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();
}
示例14: getLoggerName
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String getLoggerName(LogRecord res) {
return res.getLoggerName();
}
示例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();
}