#17 support for Java2 1.4 logging

closed
nobody
None
5
2009-03-14
2003-02-08
Stefano Fornari
No

Something like:

public class P6SpyLogger extends FormattedLogger
implements P6Logger {
public static final String LOG_NAME = "p6spy";

protected Logger log = null;

public P6SpyLogger() {
log = Logger.getLogger(LOG_NAME);
}

public void logSQL(int connectionId,
String now ,
long elapsed ,
String category ,
String prepared ,
String sql ) {

StringBuffer sb = new StringBuffer();

sb.append(now).append(' ');
sb.append((connectionId==-1 ? "" :
String.valueOf(connectionId))).append(' ');
sb.append(category).append(' ');

if ((prepared != null) && (prepared.length() >=
0)) {
logText(sb.toString() + prepared);
}

sb.append(elapsed).append(' ');
sb.append(sql).append(' ');

logText(sb.toString());
}

public void logText(String text) {
log.info(text);
setLastEntry(text);
}

public void logException(Exception e) {
log.throwing("-", "-", e);
}
}

Discussion

  • Pat
    Pat
    2009-03-14

    duplicate

    541381

     
  • Pat
    Pat
    2009-03-14

    • status: open --> closed