public class NamedLog extends Object
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:
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:
0
for none (default)1
for ERRORS messages2
for ERRORS and WARNINGS3
for ERRORS, WARNING, and DEBUG messagesInfranet.log.log_name.enable
Enables or disables
logging to the named log. To disable logging, set to "f", "n", or zero.Constructor and Description |
---|
NamedLog() |
Modifier and Type | Method and Description |
---|---|
protected static Log |
doGetNamedLog(String name) |
static boolean |
doLog(String name,
int control)
Evaluates the control level to determine whether a log call will result
in a log entry.
|
static InputStream |
getLog(String name)
Gets the
NamedLog as an InputStream . |
static Log |
getNamedLog(String name) |
static boolean |
isLogInMemory(String name)
Determines if the log is stored in memory, rather than on disk.
|
static void |
log(String name,
int control,
String message)
Logs information to the log file.
|
static void |
log(String name,
Object src,
int control,
String message)
Logs information to the log file.
|
static void |
log(String name,
Object src,
int control,
String message,
byte[] buf)
Logs information to the log file along with a hex dump of the array of bytes.
|
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.
|
static void |
log(String name,
Object src,
int control,
Throwable thrown)
Logs information to the log file.
|
public static void log(String name, int control, String message)
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.public static void log(String name, Object src, int control, Throwable thrown)
name
- The name of the log to write to.src
- The location of the error. For example, a file name and
a line number. If src
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 logpublic static void log(String name, Object src, int control, String message, byte[] buf)
name
- The name of the log to write to.src
- The location of the error. For example, a file name and
a line number. If src
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.public static void log(String name, Object src, int control, String message, byte[] buf, int off, int len)
name
- The name of the log to write to.src
- The location of the error. For example, a file name and
a line number. If src
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 of buf
bytes to log.public static void log(String name, Object src, int control, String message)
name
- The name of the log to write to.src
- The location of the error. For example, a file name and
a line number. If src
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.public static InputStream getLog(String name)
NamedLog
as an InputStream
.name
- The name of the log to get.InputStream
of the log object.public static boolean isLogInMemory(String name)
name
- The log name.true
if the log exists in memory.public static boolean doLog(String name, int control)
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.true
if the specified control level is permitted to do
a log write.Copyright © 2003, 2023, Oracle and/or its affiliates.