www.element4solution.com

e4s.db
Class E4DBLogging

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.db.E4DBLogging

public class E4DBLogging
extends E4Object

Logging for database SQL access. SQL statements (reading or writing) can be traced into a log file, including the client and the duration time. The system settings (E4DBSettings will define if and which kind of SQL statements will be logged.

Since:
JDK 1.4

Field Summary
static java.lang.String FLAG_ERROR
           
static java.lang.String FLAG_READ
           
static java.lang.String FLAG_TEXT
           
static java.lang.String FLAG_WRITE
           
static int LOGGING_AUTO
           
static int LOGGING_NO
           
static int LOGGING_YES
           
static boolean m_init
           
static boolean m_log_reading_sql
           
static boolean m_log_writing_sql
           
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4DBLogging()
           
 
Method Summary
static java.lang.String _getSVNVersionString()
           
static void closeLogfile()
          Close the current logfile.
static java.lang.String EscapeCR(java.lang.String s)
           
 void finalize()
          Close logfile on any destroy.
static boolean isReading()
          Get the status for logging of reading SQL statements.
static boolean isWriting()
          Get the status for logging of writing SQL statements.
static void log(java.lang.String txt)
           
static void logError(E4ApplObj_Intf applobj, E4DBConnection_Intf con, java.lang.String sql, java.lang.Throwable thrw)
          Write an error to the the logfile.
static void logError(E4Client client, E4DBConnection_Intf con, java.lang.String sql, java.lang.Throwable thrw)
          Write an error to the the logfile.
static void logError(java.lang.String txt, java.lang.Throwable thrw)
          Write an error to the the logfile.
static void logReading(E4ApplObj_Intf applobj, E4DBConnection_Intf con, long timer, java.lang.String sql)
          Write an [reading-]SQL statement to the logfile.
static void logReading(E4Client client, E4DBConnection_Intf con, long timer, java.lang.String sql)
          Write an [reading-]SQL statement to the logfile.
static void logWriting(E4ApplObj_Intf applobj, E4DBConnection_Intf con, long timer, java.lang.String sql)
          Write an [writing-]SQL statement to the logfile.
static void logWriting(E4Client client, E4DBConnection_Intf con, long time, java.lang.String sql)
          Write an [reading-]SQL statement to the logfile.
static void logWriting(E4DBConnection_Intf con, long timer, java.lang.String sql)
          Write an [writing-]SQL statement to the logfile.
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, toString, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_log_reading_sql

public static boolean m_log_reading_sql

m_log_writing_sql

public static boolean m_log_writing_sql

m_init

public static boolean m_init

FLAG_READ

public static final java.lang.String FLAG_READ
See Also:
Constant Field Values

FLAG_WRITE

public static final java.lang.String FLAG_WRITE
See Also:
Constant Field Values

FLAG_ERROR

public static final java.lang.String FLAG_ERROR
See Also:
Constant Field Values

FLAG_TEXT

public static final java.lang.String FLAG_TEXT
See Also:
Constant Field Values

LOGGING_AUTO

public static final int LOGGING_AUTO
See Also:
Constant Field Values

LOGGING_YES

public static final int LOGGING_YES
See Also:
Constant Field Values

LOGGING_NO

public static final int LOGGING_NO
See Also:
Constant Field Values
Constructor Detail

E4DBLogging

public E4DBLogging()
Method Detail

logReading

public static void logReading(E4ApplObj_Intf applobj,
                              E4DBConnection_Intf con,
                              long timer,
                              java.lang.String sql)
Write an [reading-]SQL statement to the logfile. Only in the case, that reading was enabled by the system properties - (@link e4s.db.E4DBSettings#getLoggingMode()}.

Parameters:
applobj - the application object, containing information about the user
timer - the time when the SQL execution has been started
sql - the SQL statement
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logError(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, java.lang.String, java.lang.Throwable), E4DBSettings.getLoggingPath(), E4DBSettings.getLoggingMode()

logWriting

public static void logWriting(E4ApplObj_Intf applobj,
                              E4DBConnection_Intf con,
                              long timer,
                              java.lang.String sql)
Write an [writing-]SQL statement to the logfile. Only in the case, that writing was enabled by the system properties - (@link e4s.db.E4DBSettings#getLoggingMode()}.

Parameters:
applobj - the application object, containing information about the user
timer - the time when the SQL execution has been started
sql - the SQL statement
See Also:
logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logError(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, java.lang.String, java.lang.Throwable), E4DBSettings.getLoggingPath(), E4DBSettings.getLoggingMode()

logWriting

public static void logWriting(E4DBConnection_Intf con,
                              long timer,
                              java.lang.String sql)
Write an [writing-]SQL statement to the logfile. Only in the case, that writing was enabled by the system properties - (@link e4s.db.E4DBSettings#getLoggingMode()}.

Parameters:
timer - the time when the SQL execution has been started
sql - the SQL statement
See Also:
logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logError(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, java.lang.String, java.lang.Throwable), E4DBSettings.getLoggingPath(), E4DBSettings.getLoggingMode()

logReading

public static void logReading(E4Client client,
                              E4DBConnection_Intf con,
                              long timer,
                              java.lang.String sql)
Write an [reading-]SQL statement to the logfile. Only in the case, that reading was enabled by the system properties - (@link e4s.db.E4DBSettings#getLoggingMode()}.

Parameters:
client - is the current client
timer - the time when the SQL execution has been started
sql - the SQL statement
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logError(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, java.lang.String, java.lang.Throwable), E4DBSettings.getLoggingMode()

logWriting

public static void logWriting(E4Client client,
                              E4DBConnection_Intf con,
                              long time,
                              java.lang.String sql)
Write an [reading-]SQL statement to the logfile. Only in the case, that reading was enabled by the system properties - (@link e4s.db.E4DBSettings#getLoggingMode()}.

Parameters:
client - is the current client
timer - the time when the SQL execution has been started
sql - the SQL statement
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logError(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, java.lang.String, java.lang.Throwable), E4DBSettings.getLoggingPath(), E4DBSettings.getLoggingMode()

log

public static void log(java.lang.String txt)

logError

public static void logError(E4ApplObj_Intf applobj,
                            E4DBConnection_Intf con,
                            java.lang.String sql,
                            java.lang.Throwable thrw)
Write an error to the the logfile. This is done in any case, unless the logile is defined by (@link e4s.db.E4DBSettings#getLoggingPath()}.

Parameters:
applobj - the application object, containing information about the user
sql - the SQL statement
thrw - the Throwable
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), E4DBSettings.getLoggingPath()

logError

public static void logError(E4Client client,
                            E4DBConnection_Intf con,
                            java.lang.String sql,
                            java.lang.Throwable thrw)
Write an error to the the logfile. This is done in any case, unless the logile is defined by (@link e4s.db.E4DBSettings#getLoggingPath()}.

Parameters:
client - is the current client
sql - the SQL statement
thrw - the Throwable
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), E4DBSettings.getLoggingPath()

logError

public static void logError(java.lang.String txt,
                            java.lang.Throwable thrw)
Write an error to the the logfile. This is done in any case, unless the logile is defined by (@link e4s.db.E4DBSettings#getLoggingPath()}.

Parameters:
sql - the SQL statement
thrw - the Throwable
See Also:
logWriting(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String), E4DBSettings.getLoggingPath()

isReading

public static boolean isReading()
Get the status for logging of reading SQL statements.

Returns:
true if logging is enabled
See Also:
logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String)

isWriting

public static boolean isWriting()
Get the status for logging of writing SQL statements.

Returns:
true if logging is enabled
See Also:
logReading(e4s.application.E4ApplObj_Intf, e4s.db.E4DBConnection_Intf, long, java.lang.String)

closeLogfile

public static void closeLogfile()
Close the current logfile. Note, that it will be immediatly reopened by the next SQL statement, if the E4DBSettings.getLoggingPath() is defined.


finalize

public void finalize()
Close logfile on any destroy. This class will not be instantiated more than once, so this in general will happen at conditioned shutdown of Tomcat.

Overrides:
finalize in class E4Object

EscapeCR

public static java.lang.String EscapeCR(java.lang.String s)

_getSVNVersionString

public static java.lang.String _getSVNVersionString()

www.element4solution.com