Browse Source

remove timestamp from log appender helper

pull/20/head
adriancole 11 years ago
parent
commit
9fd513d268
  1. 7
      feign-core/src/main/java/feign/Logger.java

7
feign-core/src/main/java/feign/Logger.java

@ -18,7 +18,6 @@ package feign; @@ -18,7 +18,6 @@ package feign;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.logging.FileHandler;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
@ -90,18 +89,16 @@ public abstract class Logger { @@ -90,18 +89,16 @@ public abstract class Logger {
}
/**
* helper that configures jul to sanely log messages.
* helper that configures jul to sanely log messages at FINE level without additional formatting.
*/
public JavaLogger appendToFile(String logfile) {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
logger.setLevel(java.util.logging.Level.FINE);
try {
FileHandler handler = new FileHandler(logfile, true);
handler.setFormatter(new SimpleFormatter() {
@Override
public String format(LogRecord record) {
String timestamp = sdf.format(new java.util.Date(record.getMillis())); // NOPMD
return String.format("%s %s%n", timestamp, record.getMessage()); // NOPMD
return String.format("%s%n", record.getMessage()); // NOPMD
}
});
logger.addHandler(handler);

Loading…
Cancel
Save