Class NamedLog
NamedLog
class lets you use multiple logs to group messages of a
similar type into a specific log by specifying the name of the log to write to. You
must configure each named log in the Infranet.properties
file.
The name of the log to write to is added in the method.
There are two types of logging styles: by priority and by flag. Each one has a set of possible control levels that determine which messages are logged.
Logging by priority:
In priority style, you assign each message a priority level. All messages with a priority level lower than the log control level are logged. (A low number equals higher priority.) If the priority control level is not configured, all messages are logged.
Logging by flag:
In flag style, each message is tagged with a flag that specifies the error message
type. Possible flags are defined in ErrorLog
. You specify which flags will
result in a message being logged in the
Infranet.properties
file.
Configuring the Infranet.properties
file:
You must configure each log you use in the Infranet.properties
file.
Log entries consist of:
Infranet.log.log_name.file
: Full path to the log file for the application. To log messages, you must set the log path.Infranet.log.log_name.name
: The name of the log to write to.Infranet.log.log_name.style
: Specifies the logging control style. The values for this entry can be:- priority: Logs messages according to their priority level, specified by the .level entry.
- flag: Logs messages according to their type, specified by the .level entry.
Infranet.log.log_name.level
: Specifies how much information the application should log. Possible values depend on the log control style specified by the .style entry. Values for this entry can be:- For control by priority style, use a decimal value.
- For control by flag style, values can be:
0
for none (default)1
for ERRORS messages2
for ERRORS and WARNINGS3
for ERRORS, WARNING, and DEBUG messages
Infranet.log.log_name.enable
Enables or disables logging to the named log. To disable logging, set to "f", "n", or zero.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static Log
doGetNamedLog
(String name) static boolean
Evaluates the control level to determine whether a log call will result in a log entry.static InputStream
Gets theNamedLog
as anInputStream
.static Log
getNamedLog
(String name) static boolean
isLogInMemory
(String name) Determines if the log is stored in memory, rather than on disk.static void
Logs information to the log file.static void
Logs information to the log file.static void
Logs information to the log file along with a hex dump of the array of bytes.static void
Logs information to the log file along with a hex dump of the array of bytes.static void
Logs information to the log file.
-
Constructor Details
-
NamedLog
public NamedLog()
-
-
Method Details
-
getNamedLog
-
doGetNamedLog
-
log
Logs information to the log file.- Parameters:
name
- The name of the log to write to.control
- The priority level or flag, depending on the logging control style.message
- The message to log.
-
log
Logs information to the log file.- Parameters:
name
- The name of the log to write to.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.control
- The priority level or flag, depending on the logging control style.thrown
- Error or exception to log
-
log
Logs information to the log file along with a hex dump of the array of bytes.- Parameters:
name
- The name of the log to write to.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.control
- The priority level or flag, depending on the logging control style.message
- The message to log.buf
- The array of bytes to append to the message.
-
log
public static void log(String name, Object src, int control, String message, byte[] buf, int off, int len) Logs information to the log file along with a hex dump of the array of bytes.- Parameters:
name
- The name of the log to write to.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.control
- The priority level or flag, depending on the logging control style.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 log file.- Parameters:
name
- The name of the log to write to.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.control
- The priority level or flag, depending on the logging control style.message
- The message to log.
-
getLog
Gets theNamedLog
as anInputStream
.- Parameters:
name
- The name of the log to get.- Returns:
InputStream
of the log object.
-
isLogInMemory
Determines if the log is stored in memory, rather than on disk.- Parameters:
name
- The log name.- Returns:
true
if the log exists in memory.
-
doLog
Evaluates the control level to determine whether a log call will result in a log entry.- Parameters:
name
- The name of the log to write to.control
- The log priority level or flag (depending on the control style) that would be passed to the log method.- Returns:
true
if the specified control level is permitted to do a log write.
-