public class BatchFileLogger extends FileLogger
modify the spy.properties file to make p6spy use this appender by adding line appender=com.p6spy.engine.logging.appender.BatchFileLogger and commenting out the existing appender #appender=com.p6spy.engine.logging.appender.FileLogger - specify an alternative log file name in spy.properties so that diagnostic entries to spy.log made by p6spy at startup do not mess up your batch.
Here's how it works for me: logfile = spy.sql The appender writes the text of SQL statements as well as commit and rollback commands to the specified file, each on a new line. For prepared statements the effective text resulting from substitution of parameter signs with their values is written. Other event categories are logged as SQL comments ("-- " followed by the category name). Exceptions and text are silently discarded. All SQL statements except the last one will have a delimiter character ';' appended to them. This batch format works well with WinSQL. The format is hardcoded, so if you want to make it configurable you'll have to patch my patch or write your own :)
Modifier and Type | Field and Description |
---|---|
static char |
BATCH_SEPARATOR |
qlog
Constructor and Description |
---|
BatchFileLogger() |
Modifier and Type | Method and Description |
---|---|
void |
logException(Exception e) |
void |
logSQL(int connectionId,
String now,
long elapsed,
String category,
String prepared,
String sql) |
void |
logText(String text) |
void |
setLogfile(String fileName) |
setStrategy
public static final char BATCH_SEPARATOR
public void logException(Exception e)
logException
in interface P6Logger
logException
in class StdoutLogger
public void logSQL(int connectionId, String now, long elapsed, String category, String prepared, String sql)
logSQL
in interface P6Logger
logSQL
in class FormattedLogger
public void logText(String text)
logText
in interface P6Logger
logText
in class StdoutLogger
public void setLogfile(String fileName)
setLogfile
in class FileLogger
Copyright © 2002-2014 P6Spy. All Rights Reserved.