Class Log
All log entries are preceded by the name of the currently executing thread,
enclosed in {}'s, and the current time in hours, minutes, seconds, and
milliseconds, enclosed in []'s. Example:
{Thread-5} [20:14:03.244] Conn: Sending Request
When the class is loaded, two java system properties are read: HTTPClient.log.file and HTTPClient.log.mask. The first one, if set, causes all logging to be redirected to the file with the given name. The second one, if set, is used for setting which facilities are enabled; the value must be the bitwise OR ('|') of the values of the desired enabled facilities. E.g. a value of 3 would enable logging for the HTTPConnection and HTTPResponse, a value of 16 would enable cookie related logging, and a value of 8 would enable authorization related logging; a value of -1 would enable logging for all facilities. By default logging is disabled.
- Since:
- V0.3-3
- Version:
- 0.3-3 06/05/2001
- Author:
- Ronald Tschal�r
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAll the facilities - for use insetLogging(-1)static final intThe Authorization facility (8)static final intThe HTTPConnection facility (1)static final intThe Cookies facility (16)static final intThe StreamDemultiplexor facility (4)static final intThe Modules facility (32)static final intThe HTTPResponse facility (2)static final intThe Socks facility (64)static final intThe ULRConnection facility (128) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisEnabled(int facility) Check whether logging for the given facility is enabled or not.static voidsetLogging(int facilities, boolean enable) Enable or disable logging for the given facilities.static voidsetLogWriter(Writer log, boolean closeWhenDone) Set the writer to which to log.static voidWrite the given message to the current log if logging for the given facility is enabled.static voidwrite(int facility, String prefix, ByteArrayOutputStream buf) Write the contents of the given buffer to the current log if logging for the given facility is enabled.static voidWrite the stack trace of the given exception to the current log if logging for the given facility is enabled.
-
Field Details
-
CONN
public static final int CONNThe HTTPConnection facility (1)- See Also:
-
RESP
public static final int RESPThe HTTPResponse facility (2)- See Also:
-
DEMUX
public static final int DEMUXThe StreamDemultiplexor facility (4)- See Also:
-
AUTH
public static final int AUTHThe Authorization facility (8)- See Also:
-
COOKI
public static final int COOKIThe Cookies facility (16)- See Also:
-
MODS
public static final int MODSThe Modules facility (32)- See Also:
-
SOCKS
public static final int SOCKSThe Socks facility (64)- See Also:
-
URLC
public static final int URLCThe ULRConnection facility (128)- See Also:
-
ALL
public static final int ALLAll the facilities - for use insetLogging(-1)- See Also:
-
-
Method Details
-
write
Write the given message to the current log if logging for the given facility is enabled.- Parameters:
facility- the facility which is logging the messagemsg- the message to log
-
write
Write the stack trace of the given exception to the current log if logging for the given facility is enabled.- Parameters:
facility- the facility which is logging the messageprefix- the string with which to prefix the stack trace; may be nullt- the exception to log
-
write
Write the contents of the given buffer to the current log if logging for the given facility is enabled.- Parameters:
facility- the facility which is logging the messageprefix- the string with which to prefix the buffer contents; may be nullbuf- the buffer to dump
-
isEnabled
public static boolean isEnabled(int facility) Check whether logging for the given facility is enabled or not.- Parameters:
facility- the facility to check- Returns:
- true if logging for the given facility is enable; false otherwise
-
setLogging
public static void setLogging(int facilities, boolean enable) Enable or disable logging for the given facilities.- Parameters:
facilities- the facilities for which to enable or disable logging. This is bitwise OR ('|') of all the desired facilities; useALLto affect all facilitiesenable- if true, enable logging for the chosen facilities; if false, disable logging for them.
-
setLogWriter
Set the writer to which to log. By default, things are logged to System.err.- Parameters:
log- the writer to log to; if null, nothing is changedcloseWhenDone- if true, close this stream when a new stream is set again
-