1 2 24 package com.sun.enterprise.server.logging; 25 26 27 28 import java.util.logging.SimpleFormatter ; 29 import java.util.logging.LogRecord ; 30 31 import java.text.MessageFormat ; 32 33 import java.io.PrintWriter ; 34 import java.io.StringWriter ; 35 36 37 42 public class ServerFormatter extends SimpleFormatter { 43 44 private MessageFormat formatter; 45 46 private static final String lineSeparator = 51 (String ) java.security.AccessController 52 .doPrivileged(new sun.security.action 53 .GetPropertyAction("line.separator")); 54 private static final String fieldSeparator = " "; 55 56 64 public synchronized String format(LogRecord record) { 65 66 StringBuffer sb = new StringBuffer (); 67 68 String message = formatMessage(record); 70 71 sb.append(message); 72 73 if (record.getThrown() != null) { 75 try { 76 StringWriter sw = new StringWriter (); 77 PrintWriter pw = new PrintWriter (sw); 78 79 record.getThrown().printStackTrace(pw); 80 pw.close(); 81 sb.append(lineSeparator); 82 sb.append(sw.toString()); 83 } catch (Exception ex) {} 84 } 85 sb.append(lineSeparator); 86 87 return sb.toString(); 88 } 89 } 90 91 | Popular Tags |