List of usage examples for java.util.logging LogRecord getMessage
public String getMessage()
From source file:brut.apktool.Main.java
private static void setupLogging(Verbosity verbosity) { Logger logger = Logger.getLogger(""); for (Handler handler : logger.getHandlers()) { logger.removeHandler(handler);/*from ww w .j a va 2s . com*/ } LogManager.getLogManager().reset(); if (verbosity == Verbosity.QUIET) { return; } Handler handler = new Handler() { @Override public void publish(LogRecord record) { if (getFormatter() == null) { setFormatter(new SimpleFormatter()); } try { String message = getFormatter().format(record); if (record.getLevel().intValue() >= Level.WARNING.intValue()) { System.err.write(message.getBytes()); } else { System.out.write(message.getBytes()); } } catch (Exception exception) { reportError(null, exception, ErrorManager.FORMAT_FAILURE); } } @Override public void close() throws SecurityException { } @Override public void flush() { } }; logger.addHandler(handler); if (verbosity == Verbosity.VERBOSE) { handler.setLevel(Level.ALL); logger.setLevel(Level.ALL); } else { handler.setFormatter(new Formatter() { @Override public String format(LogRecord record) { return record.getLevel().toString().charAt(0) + ": " + record.getMessage() + System.getProperty("line.separator"); } }); } }
From source file:org.geoserver.importer.rest.ImportJSONWriter.java
void messages(List<LogRecord> records) { if (!records.isEmpty()) { json.key("messages"); json.array();//from w w w .ja va2s . co m for (int i = 0; i < records.size(); i++) { LogRecord record = records.get(i); json.object(); json.key("level").value(record.getLevel().toString()); json.key("message").value(record.getMessage()); json.endObject(); } json.endArray(); } }
From source file:org.fornax.cartridges.sculptor.smartclient.server.util.UnifiedFormatter.java
@Override public String format(LogRecord record) { String username = "ANONYMOUS"; if (SecurityContextHolder.getContext() != null && SecurityContextHolder.getContext().getAuthentication() != null && SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null) { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal instanceof User) { username = ((User) principal).getUsername(); } else {/*from w w w . j av a 2s . c o m*/ username = principal.toString(); } } int dotIndex = record.getSourceClassName().lastIndexOf("."); String className = record.getSourceClassName().substring(dotIndex != -1 ? dotIndex + 1 : 0); String msg = record.getMessage(); if (record.getParameters() != null && record.getParameters().length > 0) { msg = MessageFormat.format(record.getMessage(), record.getParameters()); } if (record.getThrown() != null) { Throwable thrown = record.getThrown(); StringWriter result = new StringWriter(); thrown.printStackTrace(new PrintWriter(result)); result.flush(); msg += "\n" + result.getBuffer(); } return FST + dateFormat.format(record.getMillis()) + FET + FSEP + RST + FST + record.getLevel() + FET + FSEP + FST + className + "." + record.getSourceMethodName() + FET + FSEP + FST + username + FET + FSEP + FST + record.getThreadID() + FET + FSEP + FST + msg + FET + RET; }
From source file:nu.nethome.home.impl.HomeServer.java
private boolean isLogRecordInBlacklist(LogRecord record) { if (record.getMessage() == null) { return false; }/* ww w. j av a2 s. c o m*/ return record.getMessage().startsWith("Prefs file removed in background") || record.getMessage().startsWith("Could not open/create prefs root node") || record.getMessage().startsWith("SAAJ0009"); }
From source file:org.apache.shindig.gadgets.oauth.OAuthFetcherTest.java
private String getLogText() { StringBuilder logText = new StringBuilder(); for (LogRecord record : logRecords) { logText.append(record.getMessage()); }/*from w w w . ja v a2 s. c o m*/ return logText.toString(); }
From source file:org.apache.shindig.gadgets.oauth.OAuthRequestTest.java
private String getLogText() { StringBuilder logText = new StringBuilder(); for (LogRecord record : logRecords) { logText.append(record.getMessage()); if (record.getThrown() != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); record.getThrown().printStackTrace(pw); pw.flush();/*from w w w.j a v a 2 s .co m*/ logText.append(sw.toString()); } } return logText.toString(); }