|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectfwpUtil.Logger
public class Logger
Title: Logger.
Description: A basic logger capability which uses the same logging levels as the much larger standard Java logger.
Copyright: Copyright (c) 2011
Field Summary | |
---|---|
static int |
ALL
|
static int |
CONFIG
|
static int |
FINE
|
static int |
FINER
|
static int |
FINEST
|
static int |
INFO
|
static int |
OFF
|
static int |
SEVERE
|
static int |
WARNING
|
Constructor Summary | |
---|---|
Logger()
|
Method Summary | |
---|---|
static java.lang.String |
getLogFileName()
Gets the currently set log file name. |
static java.lang.String |
getLogFilePath()
Gets the currently set log file path. |
static java.lang.String |
getlogItHelpFileName()
Gets the log help file name. |
static java.lang.String |
getLogItHelpPath()
Gets the LogIt help file path. |
static int |
getLogLevel()
Gets the current logging level. |
static void |
setLogFileName(java.lang.String fileName)
Sets the log file name. |
static void |
setLogFilePath(java.lang.String pathName)
Sets the log file path. |
static void |
setlogItHelpFileName(java.lang.String fileName)
Sets the log help file name. |
static void |
setLogItHelpPath(java.lang.String pathName)
Sets the LogIt help file path. |
static void |
setLogLevel(int level)
Sets the logging level. |
static void |
startLogger(java.lang.String logPath,
java.lang.String logName,
java.lang.String helpPath,
java.lang.String helpName)
Creates a program flow and data logging capability. |
java.lang.String |
toString()
Returns the name of the class. |
static void |
writeLog(int level,
java.lang.String textMessage)
Write a message to the log file if the level parameter is greater than the currently set logging level. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ALL
public static final int CONFIG
public static final int FINE
public static final int FINER
public static final int FINEST
public static final int INFO
public static final int OFF
public static final int SEVERE
public static final int WARNING
Constructor Detail |
---|
public Logger()
Method Detail |
---|
public static java.lang.String getLogFileName()
public static java.lang.String getLogFilePath()
public static java.lang.String getlogItHelpFileName()
public static java.lang.String getLogItHelpPath()
public static int getLogLevel()
public static void setLogFileName(java.lang.String fileName)
fileName
- The log file name.public static void setLogFilePath(java.lang.String pathName)
pathName
- A String defining the path to the log file. This string
must end with a file separator.public static void setlogItHelpFileName(java.lang.String fileName)
fileName
- The log help file name.public static void setLogItHelpPath(java.lang.String pathName)
pathName
- A String defining the path to the LogIt help file.
This string must end with a file separator.public static void setLogLevel(int level)
level
- Logger.OFF, Logger.SEVERE, Logger.WARNING, Logger.INFO,
Logger.CONFIG, Logger.FINE, Logger.FINER, Logger.FINEST, and Logger.ALL.public static void startLogger(java.lang.String logPath, java.lang.String logName, java.lang.String helpPath, java.lang.String helpName)
When activated, the Logger directs all logging messages as well as all System.out and System.err output to a disk based text file. Program generated log messages and exception stack traces are also directed to the file in the exact order they were generated. Nine levels of logging are supported: Logger.OFF, Logger.SEVERE, Logger.WARNING, Logger.INFO, Logger.CONFIG, Logger.FINE, Logger.FINER, Logger.FINEST, and Logger.ALL.
The log file name and path are set by the parameters passed by the calling method.
The Logger is started with:
Logger.startLogger(logPath, LogName, helpPath, helpName);
Set a new logging level with : Logger.setLogLevel(logger.CONFIG);
When a writeLog call is made, the value of the level parameter is tested against the value passed in the last call to setLogLevel. If the value is greater, then the log message is written to the log file. In the list above, the logging levels are listed in decreasing order were OFF has the greatest value and ALL has the lowest.
filePath
- The path to the directory which is to hold the log file.
This string must end with a file separator appropriate for the system on
which the program is running. For example:
String logPath = System.getProperty("user.dir")
+ System.getProperty("file.separator");
logName
- The name of the log file.
For example: String logFileName = "Log.txt";
helpPath
- The path to the LogIt htm help file. Unless there is
a reason not to, the help file could easily go into the same
directory as the log file.
helpName
- The name of the LogIt htm help file.
For example: String helpFileName = "LogItHelp.htm"; // The default name
Example usage: The following code can be copied into program initialization area and it will do everyting necessary to get the logger going. The log file will be placed in the directory where the program is located. The default LogIt help file () should also be placed it that directory. These files do not need to be co-located and can be placed anywhere.
See the Logger documentation in the fwpUtil directory for the example.
public java.lang.String toString()
toString
in class java.lang.Object
Logger LogFile=D:\A JOptionPanel\Log.txt Log Level=1 HelpFile=D:\A JOptionPanel\LogItHelp.htm
public static void writeLog(int level, java.lang.String textMessage)
level
- Logger.OFF, Logger.SEVERE, Logger.WARNING, Logger.INFO,
Logger.CONFIG, Logger.FINE, Logger.FINER, Logger.FINEST, and Logger.ALL.
textessage
- The message to be written to the log file.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |