Package lazyj
Class Log
java.lang.Object
lazyj.Log
public final class Log
extends java.lang.Object
Logging facility. Provides package- and class-based logging level and destination folder.
- Since:
- 2006-10-16
- Author:
- costing
-
Field Summary
Fields Modifier and Type Field Description static int
ERROR
Constant for the ERROR log levelstatic int
FATAL
Constant for the FATAL log levelstatic int
FINE
Constant for the FINE log levelstatic int
FINER
Constant for the FINER log levelstatic int
FINEST
Constant for the FINEST log levelstatic int
INFO
Constant for the INFO log levelstatic int
WARNING
Constant for the WARNING log level -
Constructor Summary
Constructors Constructor Description Log()
-
Method Summary
Modifier and Type Method Description static java.lang.Integer
getLevel(java.lang.String sComponent)
Get the current logging level for a componentstatic java.lang.String
getLogDir(java.lang.String sComponent)
For a given component, get the folder where the log files should be put.static boolean
isLoggable(int level, java.lang.String sComponent)
Check if a message of a given level for a given component will be actually logged.static void
log(int level, java.lang.String sMessage)
Log a message of a given severity for a given componentstatic void
log(int level, java.lang.String sComponent, java.lang.String sMessage)
Log a message of a given severity for a given componentstatic void
log(int level, java.lang.String sComponent, java.lang.String sMessage, java.lang.Object o)
Log a message of a given severity for a given component, with an attached object.
-
Field Details
-
FATAL
public static final int FATALConstant for the FATAL log level- See Also:
- Constant Field Values
-
ERROR
public static final int ERRORConstant for the ERROR log level- See Also:
- Constant Field Values
-
WARNING
public static final int WARNINGConstant for the WARNING log level- See Also:
- Constant Field Values
-
INFO
public static final int INFOConstant for the INFO log level- See Also:
- Constant Field Values
-
FINE
public static final int FINEConstant for the FINE log level- See Also:
- Constant Field Values
-
FINER
public static final int FINERConstant for the FINER log level- See Also:
- Constant Field Values
-
FINEST
public static final int FINESTConstant for the FINEST log level- See Also:
- Constant Field Values
-
-
Constructor Details
-
Log
public Log()
-
-
Method Details
-
getLevel
public static java.lang.Integer getLevel(java.lang.String sComponent)Get the current logging level for a component- Parameters:
sComponent
- component to get the level for- Returns:
- the logging level
-
getLogDir
public static java.lang.String getLogDir(java.lang.String sComponent)For a given component, get the folder where the log files should be put.- Parameters:
sComponent
- component (class hierarchy)- Returns:
- the target log dir
-
isLoggable
public static boolean isLoggable(int level, java.lang.String sComponent)Check if a message of a given level for a given component will be actually logged. If it would not be logged then it makes no sense to try to log the message in the first place. You should use the logger with constructions like this when the log message is complicated to build:
if (Log.isLoggable(Log.DEBUG, "class.name")){ Log.log(Log.DEBUG, "class.name", "Some complicated message here : "+object.toString()); }
- Parameters:
level
- desired logging levelsComponent
- component- Returns:
- true if the message will be logged, false otherwise
-
log
public static void log(int level, java.lang.String sMessage)Log a message of a given severity for a given component- Parameters:
level
- severity of the message. Check the constants in this class for possible values.sMessage
- message to log
-
log
public static void log(int level, java.lang.String sComponent, java.lang.String sMessage)Log a message of a given severity for a given component- Parameters:
level
- severity of the message. Check the constants in this class for possible values.sComponent
- component name. Usually "servlet_zone/servlet_name", but could be the class name or something else you wantsMessage
- message to log
-
log
public static void log(int level, java.lang.String sComponent, java.lang.String sMessage, java.lang.Object o)Log a message of a given severity for a given component, with an attached object.- Parameters:
level
- severity of the message. Check the constants in this class for possible values.sComponent
- component name. Usually "servlet_zone/servlet_name", but could be the class name or something else you wantsMessage
- message to logo
- object to attach, it is intended for use with a Throwable here, but works for any other objects too by invoking the .toString() method on them
-