|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.websphere.als.AnalysisLogger
This is the entry into the logging facility. Any application needs to log data must create an instance of this class using the appropriate constructor. Since this class listens on the ServletContext events to determine when to log data to the persistent storage, to use it in an EJB, pass null for the ServletContext so that it doesn't listen for the ServletContext events. And in this case, the application is responsible for calling 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
Field Summary | |
---|---|
protected static com.ibm.ejs.ras.TraceComponent |
myTracer
|
Constructor Summary | |
---|---|
AnalysisLogger(javax.servlet.ServletContext sc,
Logger l)
Constructs an AnalysisLogger object with the default cache size of 50 entries. |
|
AnalysisLogger(javax.servlet.ServletContext sc,
Logger l,
int maxBufferSize)
Constructs an AnalysisLogger object. |
Method Summary | |
---|---|
static void |
debug(java.lang.Exception e)
|
void |
flush()
Flushes the data in the cache. |
java.lang.String |
getAppID()
Returns the current application ID. |
boolean |
getAutoSession()
Returns the auto-create session flag. |
boolean |
getCookieLogging()
Returns the COOKIE logging flag. |
boolean |
getHttpLogging()
Returns the HTTP logging flag. |
Logger |
getLogger()
Returns the current Logger object. |
int |
getLogSize()
Returns the number of log entries currently in the buffer awaiting to be written to the permanent storage. |
boolean |
isEnabled()
Returns the logging enabled flag. |
void |
log(javax.servlet.http.HttpServletRequest hsr,
java.lang.String data)
Logs the specified data. |
void |
log(javax.servlet.http.HttpServletRequest hsr,
java.lang.String key,
java.lang.String value)
Logs the specified data. |
void |
setAppID(java.lang.String appID)
Sets the application ID. |
void |
setAutoSession(boolean value)
Sets the auto-create session flag to value. |
void |
setCookieLogging(boolean value)
Sets the COOKIE logging flag to value. |
void |
setEnabled(boolean value)
Sets the logging enabled flag to value. |
void |
setHttpLogging(boolean value)
Sets the HTTP logging flag to value. |
void |
terminate()
Stops logging and releases all associated resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static com.ibm.ejs.ras.TraceComponent myTracer
Constructor Detail |
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
Method Detail |
public void log(javax.servlet.http.HttpServletRequest hsr, java.lang.String data) throws java.lang.Exception
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
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
- - value to set enable flag topublic boolean isEnabled()
public void setHttpLogging(boolean value)
value
- - value to set HTTP logging flag topublic boolean getHttpLogging()
public void setCookieLogging(boolean value)
value
- - value to set COOKIE logging flag topublic boolean getCookieLogging()
public void setAutoSession(boolean value)
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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |