public class AnalysisLogger
extends java.lang.Object
flush
method at the
appropriate interval. Method getLogSize
may be used as a
determination criteria.
There are 3 persistent storage implementations: Database, File, and
HTTP. Use appropriate constructor to enable each one. The Database
persistence is implemented by DatabaseLogger
class. The application
is responsible for setting up the database and the table as defined by
the DatabaseLogger
class. This class works with any database
supports JDBC. The File persistence is implemented by FileLogger
class.
FileLogger
is not clusterable; that is, it must be defined on
all machines participating in a cluster. The HTTP persistence is implemented
by HttpLogger
class. It supports both HTTP and HTTPS transport.
However, HTTPS is not recommended if the traffic volume is high.
Application may define custom-logger by implementing the interface Logger. To enable debug trace, set com.ibm.websphere.als.*=all=enabled.
Sample usage for IBM DB2: DatabaseLogger dblogger = new DatabaseLogger(ds, "CURRENT TIMESTAMP", "WAS.ALS", "db2admin", "db2admin"); AnalysisLogger logger = new AnalysisLogger(context, dblogger); ... logger.log(request, "sample=testing;");
Logger
,
DatabaseLogger
,
FileLogger
,
HttpLogger
Modifier and Type | Field and Description |
---|---|
protected static com.ibm.ejs.ras.TraceComponent |
myTracer
Deprecated.
|
Constructor and Description |
---|
AnalysisLogger(javax.servlet.ServletContext sc,
Logger l)
Deprecated.
Constructs an AnalysisLogger object with the default cache size
of 50 entries.
|
AnalysisLogger(javax.servlet.ServletContext sc,
Logger l,
int maxBufferSize)
Deprecated.
Constructs an AnalysisLogger object.
|
Modifier and Type | Method and Description |
---|---|
static void |
debug(java.lang.Exception e)
Deprecated.
|
void |
flush()
Deprecated.
Flushes the data in the cache.
|
java.lang.String |
getAppID()
Deprecated.
Returns the current application ID.
|
boolean |
getAutoSession()
Deprecated.
Returns the auto-create session flag.
|
boolean |
getCookieLogging()
Deprecated.
Returns the COOKIE logging flag.
|
boolean |
getHttpLogging()
Deprecated.
Returns the HTTP logging flag.
|
Logger |
getLogger()
Deprecated.
Returns the current Logger object.
|
int |
getLogSize()
Deprecated.
Returns the number of log entries currently in the buffer
awaiting to be written to the permanent storage.
|
boolean |
isEnabled()
Deprecated.
Returns the logging enabled flag.
|
void |
log(javax.servlet.http.HttpServletRequest hsr,
java.lang.String data)
Deprecated.
Logs the specified data.
|
void |
log(javax.servlet.http.HttpServletRequest hsr,
java.lang.String key,
java.lang.String value)
Deprecated.
Logs the specified data.
|
void |
setAppID(java.lang.String appID)
Deprecated.
Sets the application ID.
|
void |
setAutoSession(boolean value)
Deprecated.
Sets the auto-create session flag to
value . |
void |
setCookieLogging(boolean value)
Deprecated.
Sets the COOKIE logging flag to
value . |
void |
setEnabled(boolean value)
Deprecated.
Sets the logging enabled flag to
value . |
void |
setHttpLogging(boolean value)
Deprecated.
Sets the HTTP logging flag to
value . |
void |
terminate()
Deprecated.
Stops logging and releases all associated resources.
|
public AnalysisLogger(javax.servlet.ServletContext sc, Logger l)
sc
- a ServletContext of the webapp requesting the
logging. If this param is null, flusing the cache
is done as part of log() invocation. This behavior
is necessary for EJB logging.l
- a Logger responsible for writing data to persistent
storageLogger
public AnalysisLogger(javax.servlet.ServletContext sc, Logger l, int maxBufferSize)
sc
- a ServletContext of the webapp requesting the
logging. If this param is null, flusing the cache
is done as part of log() invocation. This behavior
is necessary for EJB logging.l
- a Logger responsible for writing data to persistent
storagemaxBufferSize
- a maximum number of entries cached in the buffer
before calling flush()
Logger
public void log(javax.servlet.http.HttpServletRequest hsr, java.lang.String data) throws java.lang.Exception
maxBufferSize
specified in the constructor, or the time elapse since
last flush has been longer than a minute. The format
of the data is key=value;
. Note that the semicolon
is appended to the value automatically.hsr
- - the HttpServletRequest of the request. If this param
is null, a unique sequence number is generated
for the REQID, and the session ID is zerodata
- - a well-formated and semicolon-terminated stringjava.lang.Exception
- - thrown when unable to write datapublic void log(javax.servlet.http.HttpServletRequest hsr, java.lang.String key, java.lang.String value) throws java.lang.Exception
maxBufferSize
specified in the constructor, or the time elapse since
last flush has been longer than a minute. The format
of the data is key=value;
. Note that the semicolon
is appended to the value automatically.hsr
- - the HttpServletRequest of the request. If this param
is null, a unique sequence number is generated
for the REQID, and the session ID is zerokey
- - the key of the datavalue
- - the value of the datajava.lang.Exception
- - thrown when unable to write datapublic void flush() throws java.lang.Exception
java.lang.Exception
- - thrown when unable to write datagetLogSize()
public void setEnabled(boolean value)
value
. This is a
convenient way for the application to turn logging on or off.
The default value is true
.value
- - value to set enable flag topublic boolean isEnabled()
public void setHttpLogging(boolean value)
value
. Application
should turn off HTTP logging if it is not needed. If this
flag is off, the HttpData field that is logged will be null.
The default value is true
.value
- - value to set HTTP logging flag topublic boolean getHttpLogging()
public void setCookieLogging(boolean value)
value
. Application
should turn off COOKIE logging if it is not needed. If this
flag is false, the COOKIE field that is logged will be null.
The default value is true
.value
- - value to set COOKIE logging flag topublic boolean getCookieLogging()
public void setAutoSession(boolean value)
value
. If this
flag is true and if the session object doesn't exist for a request,
a session object will be automatically created before processing
logging for that request. The default value is true
.
If the application doesn't track session and auto-create is true,
the log
method should be called at least once before
any output is written to the response object
value
- - value to set auto-create session flag topublic boolean getAutoSession()
public Logger getLogger()
public void setAppID(java.lang.String appID)
appID
- - a String representing the application ID, limited
to 128 characterspublic java.lang.String getAppID()
public int getLogSize()
public void terminate()
public static void debug(java.lang.Exception e)