Package com.portal.pcm
Class DefaultLog
java.lang.Object
com.portal.pcm.DefaultLog
The
DefaultLog
class is a convenience class for debug and error
logging using the default log javapcm.log.
The JavaPCM library logs messages to this log, but the log can also be used by client
applications. Use the DefualtLog.log
methods to write to this log.
DefaultLog
uses "flag" style log control.
With flag style control, each message is tagged with a flag that specifies the
error message type. Possible flag values are defined in ErrorLog
. Which
messages are logged is based on the log level set in the configuration file.
Configure the Infranet.properties
file to set the levels and enable
logging. The entries are:
- infranet.log.file: The file path (the default is javapcm.log).
- infranet.log.level: Specifies which flags will result in a log entry.
0
for none (default).1
for ERROR messages2
for ERROR and WARNING messages3
for ERROR, WARNING, and DEBUG messages
- infranet.log.logallebuf:
true
to log all EBufExceptions (the default is false)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
doLog
(int control) Evaluates the control level to determine whether a log call will result in a log entry.static InputStream
getLog()
Retrieves theDefaultLog
as anInputStream
.static boolean
Determines if the message logged is stored in memory rather than on disk.static void
Logs information to the default log file.static void
Logs information to the default log file.static void
Logs a message to the log file along with a hex dump of the array of bytes.static void
Logs information to the default log file.static void
Logs the error message retrieved from theThrowable
object thrown by an error.static void
Logs information to the default log file.static void
Logs a message to the default log file.static void
setFlags
(int flags) Sets theDefaultLog
message flag.static void
Sets the application name.static void
Sets theDefaultLog
file path name.static void
Set alternative log writer.
-
Constructor Details
-
DefaultLog
public DefaultLog()
-
-
Method Details
-
setName
Sets the application name.- Parameters:
name
- The name of the application doing the logging.
-
setPath
Sets theDefaultLog
file path name.- Parameters:
path
- The new log path.
-
setWriter
Set alternative log writer.- Parameters:
writer
- NewWriter
to write logs
-
setFlags
public static void setFlags(int flags) Sets theDefaultLog
message flag.- Parameters:
flags
- The message type.
-
log
Logs a message to the default log file.- Parameters:
message
- The message to log.
-
log
Logs information to the default log file.- Parameters:
src
- The location of the error. For example, a file name and a line number. Ifsrc
is a string, it is used to describe the source. Otherwise, the name of the object class is used.message
- The message to log.
-
log
Logs information to the default log file.- Parameters:
flags
- TheDefaultLog
message type.message
- The message to log.
-
log
Logs the error message retrieved from theThrowable
object thrown by an error.- Parameters:
src
- The location of the error. For example, a file name and a line number. Ifsrc
is a string, it is used to describe the source. Otherwise, the name of the object class is used.flags
- TheDefaultLog
message type.thrown
- the thrown error or exception to log.
-
log
Logs a message to the log file along with a hex dump of the array of bytes.- Parameters:
src
- The location of the error. For example, a file name and a line number. Ifsrc
is a string, it is used to describe the source. Otherwise, the name of the object class is used.flags
- TheDefaultLog
message type.message
- The message to log.buf
- The array of bytes to append to the message.
-
log
Logs information to the default log file.- Parameters:
src
- The location of the error. For example, a file name and a line number. Ifsrc
is a string, it is used to describe the source. Otherwise, the name of the object class is used.flags
- TheDefaultLog
message type.message
- The message to log.buf
- The array of bytes to append to the message.off
- Offset into the buffer; the position at which to start the hex dump.len
- Number ofbuf
bytes to log.
-
log
Logs information to the default log file.- Parameters:
src
- The location of the error. For example, a file name and a line number. Ifsrc
is a string, it is used to describe the source. Otherwise, the name of the object class is used.flags
- TheDefaultLog
message type.message
- The message to log.
-
getLog
Retrieves theDefaultLog
as anInputStream
.- Returns:
- An
InputStream
of theDefaultLog
object.
-
isLogInMemory
public static boolean isLogInMemory()Determines if the message logged is stored in memory rather than on disk.- Returns:
true
if the log is in memory.
-
doLog
public static boolean doLog(int control) Evaluates the control level to determine whether a log call will result in a log entry.- Parameters:
control
- The log message flag that would be passed to the log method.- Returns:
true
if the specified control level permits writing to the log file.
-