|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.stratelia.silverpeas.silvertrace.SilverTrace
public class SilverTrace
SilverTrace is the trace tool used in silverpeas to trace debug, running infos and errors. This is a 'fully' static class. All functions could be called directly and is thread-safe. The trace functions are : debug, info, warn, error, fatal.
Field Summary | |
---|---|
static int |
APPENDER_ALL
Used to remove all appenders attached to a module |
static int |
APPENDER_CONSOLE
Appender sending informations on console |
static int |
APPENDER_FILE
Appender sending informations on file |
static int |
APPENDER_MAIL
Appender sending informations mail |
static int |
APPENDER_ROLLING_FILE
Appender sending informations on rolling file |
protected static Properties |
availableModules
|
protected static String |
errorDir
|
protected static boolean |
initFinished
|
static String |
MODULE_ADMIN
The Admin module's name |
static String |
MODULE_BUS
The Bus module's name |
static String |
MODULE_COMPONENTS
The Components module's name |
static String |
MODULE_ERROR_AND_FATAL
The special output for ERROR and FATAL module's name |
static String |
MODULE_LIBRARIES
The Libraries module's name |
static String |
MODULE_ROOT
The silverpeas root module's name |
static String |
MODULE_SPY
The special output for SPY module's name |
static String |
ROLLING_MODE_DAILY
The trace file will be copied every day at midnight with the name : FileName.ext.year-mounth-day A new file named FileName.ext is the created and will contains the next day's traces Example : MyFile.txt.2001-07-23 |
static String |
ROLLING_MODE_HOUR
The trace file will be copied every hour with the name : FileName.ext.year-mounth-day-hour A new file named FileName.ext is the created and will contains the next hour's traces Example : MyFile.txt.2001-07-23-18 |
static String |
ROLLING_MODE_MONTH
The trace file will be copied every 1st day of a mounth with the name : FileName.ext.year-mounth A new file named FileName.ext is the created and will contains the next mounth's traces Example : MyFile.txt.2001-07 |
static String |
ROLLING_MODE_WEEK
The trace file will be copied every 1st day of a week with the name : FileName.ext.year-week A new file named FileName.ext is the created and will contains the next week's traces Example : MyFile.txt.2001-34 |
static String |
SPY_ACTION_CREATE
Create action code |
static String |
SPY_ACTION_DELETE
Delete action code |
static String |
SPY_ACTION_UPDATE
Update action code |
static int |
TRACE_LEVEL_DEBUG
Debug-level traces. |
static int |
TRACE_LEVEL_ERROR
Error-level traces |
static int |
TRACE_LEVEL_FATAL
Fatal-level traces |
static int |
TRACE_LEVEL_INFO
Info-level traces |
static int |
TRACE_LEVEL_UNKNOWN
Used in setTraceLevel to reset a level trace. |
static int |
TRACE_LEVEL_WARN
Warning-level traces |
protected static MsgTrace |
traceMessages
|
Constructor Summary | |
---|---|
SilverTrace()
|
Method Summary | |
---|---|
static void |
addAppenderConsole(String module,
String patternLayout,
String consoleName)
Add a new console appender to the module. |
static void |
addAppenderFile(String module,
String patternLayout,
String fileName,
boolean appendOnFile)
Add a new file appender to the module. |
protected static void |
addAppenderFromProperties(Properties fileProperties,
int appenderNumber,
int appenderType)
Read appender information from a property file and attach it to it's module |
static void |
addAppenderMail(String module,
String patternLayout,
String mailHost,
String mailFrom,
String mailTo,
String mailSubject)
Add a new mail appender to the module. |
static void |
addAppenderRollingFile(String module,
String patternLayout,
String fileName,
String rollingMode)
Add a new rolling file appender to the module. |
static void |
applyProperties(String filePath)
|
static void |
debug(String module,
String classe,
String message)
Trace some debug informations. |
static void |
debug(String module,
String classe,
String message,
String extraInfos)
Trace some debug informations. |
static void |
debug(String module,
String classe,
String message,
String extraInfos,
Throwable ex)
Trace some debug informations. |
static void |
debug(String module,
String classe,
String message,
Throwable ex)
Trace some debug informations. |
protected static void |
emergencyTrace(String module,
String classe,
String msgToTrace,
String extraInfos,
Throwable ex)
Method declaration |
protected static void |
emergencyTrace(String msgToTrace,
Throwable ex)
Method declaration |
static void |
error(String module,
String classe,
String messageID)
Trace some 'error' informations. |
static void |
error(String module,
String classe,
String messageID,
String extraInfos)
Trace some 'error' informations. |
static void |
error(String module,
String classe,
String messageID,
String extraInfos,
Throwable ex)
Trace some 'error' informations. |
static void |
error(String module,
String classe,
String messageID,
Throwable ex)
Trace some 'error' informations. |
static void |
fatal(String module,
String classe,
String messageID)
Trace some 'fatal error' informations. |
static void |
fatal(String module,
String classe,
String messageID,
String extraInfos)
Trace some 'fatal error' informations. |
static void |
fatal(String module,
String classe,
String messageID,
String extraInfos,
Throwable ex)
Trace some 'fatal error' informations. |
static void |
fatal(String module,
String classe,
String messageID,
Throwable ex)
Trace some 'fatal error' informations. |
protected static String |
formatErrorAndFatalMessage(String module,
String classe,
String messageID,
String extraInfos,
Throwable ex)
Format the trace message for the Error and Fatal specific case |
protected static String |
formatSpyMessage(String spaceId,
String instanceId,
String objectId,
String userId,
String actionId)
Method declaration |
protected static String |
formatTraceMessage(String module,
String classe,
String messageID,
String message,
String extraInfos)
Format the trace message to send to log4j |
static Properties |
getAppender(String module,
int typeOfAppender)
The purpose of this function is just to return informations about an appender for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class... |
protected static String |
getAppenderName(String module,
int typeOfAppender)
Return the name of the appender depending on it's attached module and type |
static int |
getAvailableAppenders(String module)
The purpose of this function is just to return the available appenders for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class... |
static String[] |
getEndFileTrace(String nbLines)
|
static Properties |
getModuleList()
The purpose of this function is just to return the list of available modules to the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class... |
protected static org.apache.log4j.Logger |
getModuleLogger(String module)
Return the category associated to a module |
static int |
getTraceLevel(String module,
boolean chained)
Get the trace level of a module. |
static String |
getTraceMessage(String messageId)
Returns the message corresponding to the MessageId in the SilverTrace default language |
static String |
getTraceMessage(String messageId,
String language)
Returns the language-dependant message corresponding to the MessageId |
static void |
info(String module,
String classe,
String messageID)
Trace some 'info' informations. |
static void |
info(String module,
String classe,
String messageID,
String extraInfos)
Trace some 'info' informations. |
static void |
info(String module,
String classe,
String messageID,
String extraInfos,
Throwable ex)
Trace some 'info' informations. |
static void |
info(String module,
String classe,
String messageID,
Throwable ex)
Trace some 'info' informations. |
static void |
initFromProperties(Properties fileProperties)
Loads the configuration from the properties given in argument. |
static void |
removeAppender(String module,
int typeOfAppender)
Remove appender(s) attached to a module. typeOfAppender could be one value or a mask of multiple appender types |
static void |
resetAll()
Reset all modules, messages, appenders and all set debug levels. |
static void |
setTraceLevel(String module,
int val)
Set the minimum trace level of a module. |
static void |
spy(String module,
String classe,
String spaceId,
String instanceId,
String objectId,
String userId,
String actionId)
Trace some actions (create, delete, update) done by a user on an object of an instance in a space. |
protected static String |
translateFileName(String fileName)
Translate the |
static void |
warn(String module,
String classe,
String messageID)
Trace some 'warning' informations. |
static void |
warn(String module,
String classe,
String messageID,
String extraInfos)
Trace some 'warning' informations. |
static void |
warn(String module,
String classe,
String messageID,
String extraInfos,
Throwable ex)
Trace some 'warning' informations. |
static void |
warn(String module,
String classe,
String messageID,
Throwable ex)
Trace some 'warning' informations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TRACE_LEVEL_UNKNOWN
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int TRACE_LEVEL_DEBUG
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int TRACE_LEVEL_INFO
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int TRACE_LEVEL_WARN
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int TRACE_LEVEL_ERROR
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int TRACE_LEVEL_FATAL
setTraceLevel(java.lang.String, int)
,
getTraceLevel(java.lang.String, boolean)
,
Constant Field Valuespublic static final int APPENDER_CONSOLE
addAppenderConsole(java.lang.String, java.lang.String, java.lang.String)
,
removeAppender(java.lang.String, int)
,
Constant Field Valuespublic static final int APPENDER_FILE
addAppenderFile(java.lang.String, java.lang.String, java.lang.String, boolean)
,
removeAppender(java.lang.String, int)
,
Constant Field Valuespublic static final int APPENDER_ROLLING_FILE
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
removeAppender(java.lang.String, int)
,
#ROLLING_MODE_MOUNTH
,
ROLLING_MODE_WEEK
,
ROLLING_MODE_DAILY
,
ROLLING_MODE_HOUR
,
Constant Field Valuespublic static final int APPENDER_MAIL
addAppenderMail(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
removeAppender(java.lang.String, int)
,
Constant Field Valuespublic static final int APPENDER_ALL
removeAppender(java.lang.String, int)
,
Constant Field Valuespublic static final String ROLLING_MODE_MONTH
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
Constant Field Valuespublic static final String ROLLING_MODE_WEEK
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
Constant Field Valuespublic static final String ROLLING_MODE_DAILY
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
Constant Field Valuespublic static final String ROLLING_MODE_HOUR
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
Constant Field Valuespublic static final String MODULE_ROOT
public static final String MODULE_ERROR_AND_FATAL
public static final String MODULE_SPY
public static final String SPY_ACTION_CREATE
public static final String SPY_ACTION_DELETE
public static final String SPY_ACTION_UPDATE
public static final String MODULE_BUS
public static final String MODULE_ADMIN
public static final String MODULE_COMPONENTS
public static final String MODULE_LIBRARIES
protected static final Properties availableModules
protected static final MsgTrace traceMessages
protected static String errorDir
protected static boolean initFinished
Constructor Detail |
---|
public SilverTrace()
Method Detail |
---|
public static void debug(String module, String classe, String message)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")message
- a string that will be displayed in the tracespublic static void debug(String module, String classe, String message, String extraInfos)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")message
- a string that will be displayed in the tracesextraInfos
- some extra-informations that are displayed after the message in parentesispublic static void debug(String module, String classe, String message, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")message
- a string that will be displayed in the tracesex
- the exception to tracepublic static void debug(String module, String classe, String message, String extraInfos, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")message
- a string that will be displayed in the tracesextraInfos
- some extra-informations that are displayed after the message in parentesisex
- the exception to tracepublic static void info(String module, String classe, String messageID)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")public static void info(String module, String classe, String messageID, String extraInfos)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesispublic static void info(String module, String classe, String messageID, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")ex
- the exception to tracepublic static void info(String module, String classe, String messageID, String extraInfos, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesisex
- the exception to tracepublic static void warn(String module, String classe, String messageID)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")public static void warn(String module, String classe, String messageID, String extraInfos)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesispublic static void warn(String module, String classe, String messageID, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")ex
- the exception to tracepublic static void warn(String module, String classe, String messageID, String extraInfos, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesisex
- the exception to tracepublic static void error(String module, String classe, String messageID)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")public static void error(String module, String classe, String messageID, String extraInfos)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesispublic static void error(String module, String classe, String messageID, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")ex
- the exception to tracepublic static void error(String module, String classe, String messageID, String extraInfos, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesisex
- the exception to tracepublic static void fatal(String module, String classe, String messageID)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")public static void fatal(String module, String classe, String messageID, String extraInfos)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesispublic static void fatal(String module, String classe, String messageID, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")ex
- the exception to tracepublic static void fatal(String module, String classe, String messageID, String extraInfos, Throwable ex)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")messageID
- the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")extraInfos
- some extra-informations that are displayed after the message in parentesisex
- the exception to tracepublic static void spy(String module, String classe, String spaceId, String instanceId, String objectId, String userId, String actionId)
module
- the module name (ex : root, bus, outlook, ...)classe
- the short name of the classe that call this function (ex : "MyFavoriteClass")
Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")spaceId
- instanceId
- objectId
- the object (ex. publication) which is created, deleted ou updated.userId
- the user who has created, deleted or updated.actionId
- One of the constants SPY_ACTION_CREATE, SPY_ACTION_DELETE, SPY_ACTION_UPDATE.public static void resetAll()
public static void applyProperties(String filePath)
public static void initFromProperties(Properties fileProperties)
fileProperties
- the properties to merge with the current configurationpublic static void setTraceLevel(String module, int val)
module
- the module name (ex : root, bus, outlook, ...)val
- the trace level : could be one of the TRACE_LEVEL_... values. Use
TRACE_LEVEL_UNKNOWN to remove the level condition for the module.public static int getTraceLevel(String module, boolean chained)
module
- the module name (ex : root, bus, outlook, ...)chained
- if false : return a trace level only if the module have been set with one. Else,
return TRACE_LEVEL_UNKNOWN. If true, look for the inherited trace level.
public static void addAppenderConsole(String module, String patternLayout, String consoleName)
module
- the module name (ex : root, bus, outlook, ...)patternLayout
- the things displayed in this appender, could be one of the LAYOUT_...
constantsconsoleName
- Name of the console output. If null or "", "system.out" is usedpublic static void addAppenderFile(String module, String patternLayout, String fileName, boolean appendOnFile)
module
- the module name (ex : root, bus, outlook, ...)patternLayout
- the things displayed in this appender, could be one of the LAYOUT_...
constantsfileName
- full-path name of the file where the trace are writtenappendOnFile
- true to append at the end of the existing file (if ther is one), false to
remove old file before writtingpublic static void addAppenderRollingFile(String module, String patternLayout, String fileName, String rollingMode)
module
- the module name (ex : root, bus, outlook, ...)patternLayout
- the things displayed in this appender, could be one of the LAYOUT_...
constantsfileName
- full-path name of the file where the trace are writtenrollingMode
- frequency of the rolling file, could be one of the ROLLING_MODE_...
constantspublic static void addAppenderMail(String module, String patternLayout, String mailHost, String mailFrom, String mailTo, String mailSubject)
module
- the module name (ex : root, bus, outlook, ...)patternLayout
- the things displayed in this appender, could be one of the LAYOUT_...
constantsmailHost
- host namemailFrom
- email of the sendermailTo
- target email, could be multiple targets separeted with comasmailSubject
- subject of the mailpublic static void removeAppender(String module, int typeOfAppender)
module
- the module name (ex : root, bus, outlook, ...)typeOfAppender
- could be a mask of APPENDER_... values or APPENDER_ALL to remove all
appenders attached to the modulepublic static Properties getModuleList()
public static int getAvailableAppenders(String module)
module
- the module name (ex : root, bus, outlook, ...)
public static Properties getAppender(String module, int typeOfAppender)
module
- the module name (ex : root, bus, outlook, ...)typeOfAppender
- the type of appender : one of the APPENDER_... constants
public static String getTraceMessage(String messageId)
messageId
- the message ID (ex. 'admin.MSG_ERR_GENERAL')
public static String[] getEndFileTrace(String nbLines)
public static String getTraceMessage(String messageId, String language)
messageId
- the message ID (ex. 'admin.MSG_ERR_GENERAL')language
- the language to display the message in
protected static String formatSpyMessage(String spaceId, String instanceId, String objectId, String userId, String actionId)
spaceId
- instanceId
- objectId
- userId
- actionId
-
protected static String formatErrorAndFatalMessage(String module, String classe, String messageID, String extraInfos, Throwable ex)
module
- classe
- messageID
- extraInfos
- ex
-
protected static String formatTraceMessage(String module, String classe, String messageID, String message, String extraInfos)
module
- classe
- messageID
- message
- extraInfos
-
protected static String translateFileName(String fileName)
fileName
-
protected static void addAppenderFromProperties(Properties fileProperties, int appenderNumber, int appenderType)
fileProperties
- appenderNumber
- appenderType
- protected static org.apache.log4j.Logger getModuleLogger(String module)
module
-
protected static String getAppenderName(String module, int typeOfAppender)
module
- typeOfAppender
-
protected static void emergencyTrace(String msgToTrace, Throwable ex)
msgToTrace
- ex
-
protected static void emergencyTrace(String module, String classe, String msgToTrace, String extraInfos, Throwable ex)
module
- classe
- msgToTrace
- extraInfos
- ex
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |