Package com.ibm.di.server
Class Log
- java.lang.Object
-
- com.ibm.di.server.Log
-
- All Implemented Interfaces:
java.io.Serializable
public class Log extends java.lang.Object implements java.io.Serializable
The Log object is used to log messages to logs. It keeps a list of different Loggers, all implementing LogInterface, and asks all of them to log.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Log.InternalLogger
A collection of loggers.
-
Field Summary
Fields Modifier and Type Field Description boolean
debug
The debug mode flag for the log.
-
Constructor Summary
Constructors Constructor Description Log(Log parentLog)
A constructor taking another Log as a parameter.Log(java.lang.String resourceName)
A constructor which takes only a resource name.Log(java.lang.String resourceName, Log.InternalLogger loggers)
Deprecated.Log(java.lang.String resourceName, java.lang.String category)
A constructor with both resourceName and category name
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLogger(LogInterface logger)
Add a LogInterface to internal list of loggers.void
close()
Close the output loggervoid
debug(java.lang.String res)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged.void
debug(java.lang.String res, java.lang.Object param)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged.void
debug(java.lang.String res, java.lang.Object[] params)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged.void
debug(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged.void
dump(java.lang.Object o)
This methods dumps an Object to the log file.void
dumpEntry(Entry e)
Dumps a formatted message to the logfile from the contents of an Entryvoid
error(java.lang.String res)
Log a message with error level.void
error(java.lang.String res, java.lang.Object[] params)
Log a message with error level.void
error(java.lang.String res, java.lang.Object[] params, java.lang.Throwable error)
Log a message with error level.void
error(java.lang.String res, java.lang.Object param, java.lang.Throwable error)
Log a message with error level.void
error(java.lang.String res, java.lang.String param)
Log a message with error level.void
error(java.lang.String res, java.lang.String param1, java.lang.String param2)
Log a message with error level.void
error(java.lang.String res, java.lang.Throwable error)
Log a message with error level.void
exception(java.lang.String res)
Throws a new exception with a custom message.void
exception(java.lang.String res, java.lang.Object param)
Throws a new exception with a custom message.void
exception(java.lang.String res, java.lang.Object[] params)
Throws a new exception with a custom message.void
exception(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Throws a new exception with a custom message.void
fatal(java.lang.String res)
Log a message with fatal level.void
fatal(java.lang.String res, java.lang.Object param)
Log a message with fatal level.void
fatal(java.lang.String res, java.lang.Object[] params)
Log a message with fatal level.void
fatal(java.lang.String res, java.lang.Object param, java.lang.Throwable err)
Log a message with fatal level.void
fatal(java.lang.String res, java.lang.Throwable err)
Log a message with fatal level.void
fine(java.lang.String res)
Log a message with debug level.void
fine(java.lang.String res, java.lang.Object param)
Log a message with debug level.void
fine(java.lang.String res, java.lang.Object[] params)
Log a message with debug level.void
fine(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with debug level.java.lang.String
getCategory()
Returns the category for this LogLogInterface
getClassLogger(java.lang.String className)
Returns a LogInterface with the given class Name.boolean
getDebug()
Return the value of the debug parameterjava.util.Vector<org.apache.logging.log4j.Logger>
getLoggers()
Returns a Vector containing all org.apache.log4j.Logger objects used by this Log.java.lang.String
getPrefix()
Returns the prefix to be prepended to all messagesjava.lang.String
getString(java.lang.String resource)
Return the NLS string given the resource.java.lang.String
getString(java.lang.String resource, java.lang.Object param)
Return the NLS string given the resource and a parameter.java.lang.String
getString(java.lang.String resource, java.lang.Object[] params)
Return the NLS string given the resource and an array of parametersjava.lang.String
getString(java.lang.String resource, java.lang.Object param1, java.lang.Object param2)
Return the NLS string given the resource and two parametersSystemLogAppender
getSystemLog()
Returns the SystemLogAppender if any, in the Log.TDILog4j
getTDILog4j()
Returns a TDILog4j Logger connected to this Log object.void
info(java.lang.String res)
Log a message with info level.void
info(java.lang.String res, java.lang.Object param)
Log a message with info level.void
info(java.lang.String res, java.lang.Object[] params)
Log a message with info level.void
info(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with info level.boolean
isDebugEnabled()
Checks whether debug is enabled.static boolean
isLoggingEnabled()
Returns whether TDI logging is active or disabled.void
log(java.lang.String level, java.lang.String msg)
Log a message with the specified level.void
logdebug(java.lang.String msg)
Log a message with info level if the debug mode flag istrue
, otherwise an debug level message is logged.void
logerror(java.lang.String msg)
Log a message with error level.void
logerror(java.lang.String msg, java.lang.Throwable error)
Log a message with error level with an additional Throwable object.void
logfatal(java.lang.String msg)
Log a message with fatal level.void
logfine(java.lang.String msg)
Logs a message to the output stream.void
loginfo(java.lang.String msg)
Log a message with info level.void
logwarn(java.lang.String msg)
Log a message with warning level.void
removeLogger(LogInterface logger)
Remove a LogInterface from the internal list of loggers.void
setCategory(java.lang.String category)
Sets the category for this Logvoid
setDebug(boolean debug)
Sets debug parameterstatic void
setLoggingEnabled()
Checks the com.ibm.di.logging.enabled property to see if logging is enabledstatic void
setLoggingEnabled(boolean enabled)
Disables or enables TDI logging.void
setPrefix(java.lang.String prefix)
Sets a prefix to be prepended to all messagesvoid
setSystemLogAppender(SystemLogAppender tmp)
void
warn(java.lang.String res)
Log a message with warning level.void
warn(java.lang.String res, java.lang.Object param)
Log a message with warning level.void
warn(java.lang.String res, java.lang.Object[] params)
Log a message with warning level.void
warn(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with warning level.
-
-
-
Constructor Detail
-
Log
public Log(java.lang.String resourceName)
A constructor which takes only a resource name.- Parameters:
resourceName
- Name used both as translation resource name and the category name
-
Log
public Log(java.lang.String resourceName, java.lang.String category)
A constructor with both resourceName and category name- Parameters:
resourceName
- Name used for locating translation resourcecategory
- The category name for the loggers
-
Log
public Log(Log parentLog)
A constructor taking another Log as a parameter. All messages are logged to that Log's internal list of loggers.- Parameters:
parentLog
- The other Log
-
Log
@Deprecated public Log(java.lang.String resourceName, Log.InternalLogger loggers)
Deprecated.A constructor with both resourceName and an InternalLogger- Parameters:
resourceName
- Name used for locating translation resourceloggers
- Used as the list of loggers
-
-
Method Detail
-
getLoggers
public java.util.Vector<org.apache.logging.log4j.Logger> getLoggers()
Returns a Vector containing all org.apache.log4j.Logger objects used by this Log.- Returns:
- a Vector containing all Logger objects used by this Log.
-
getSystemLog
public SystemLogAppender getSystemLog()
Returns the SystemLogAppender if any, in the Log.- Returns:
-
setSystemLogAppender
public void setSystemLogAppender(SystemLogAppender tmp)
-
addLogger
public void addLogger(LogInterface logger)
Add a LogInterface to internal list of loggers.- Parameters:
logger
- The new LogInterface object.
-
removeLogger
public void removeLogger(LogInterface logger)
Remove a LogInterface from the internal list of loggers.- Parameters:
logger
- The LogInterface object.
-
getTDILog4j
public TDILog4j getTDILog4j()
Returns a TDILog4j Logger connected to this Log object.- Returns:
- the TDILog4j Logger
-
getClassLogger
public LogInterface getClassLogger(java.lang.String className) throws java.lang.Exception
Returns a LogInterface with the given class Name. An instance is created and added to the internal list of loggers.- Parameters:
className
- The class name- Returns:
- a LogInterface with the given class Name.
- Throws:
java.lang.Exception
- if problem occurs
-
setDebug
public void setDebug(boolean debug)
Sets debug parameter- Parameters:
debug
- true if debug level should be output as info
-
getDebug
public boolean getDebug()
Return the value of the debug parameter- Returns:
- the
boolean
value
-
isDebugEnabled
public boolean isDebugEnabled()
Checks whether debug is enabled.- Returns:
- true if the debug mode flag is true or any of the kept loggers has enabled debug, otherwise returns false.
-
setLoggingEnabled
public static void setLoggingEnabled()
Checks the com.ibm.di.logging.enabled property to see if logging is enabled
-
setLoggingEnabled
public static void setLoggingEnabled(boolean enabled)
Disables or enables TDI logging. All loggers are affected by this setting.- Parameters:
enabled
- iftrue
all loggers are enabled, otherwise they are disabled
-
isLoggingEnabled
public static boolean isLoggingEnabled()
Returns whether TDI logging is active or disabled.- Returns:
true
if logging is enabled, otherwisefalse
-
setCategory
public void setCategory(java.lang.String category)
Sets the category for this Log- Parameters:
category
- The category- Since:
- 7.0
-
getCategory
public java.lang.String getCategory()
Returns the category for this Log- Returns:
- The category
- Since:
- 7.0
-
setPrefix
public void setPrefix(java.lang.String prefix)
Sets a prefix to be prepended to all messages- Parameters:
prefix
-
-
getPrefix
public java.lang.String getPrefix()
Returns the prefix to be prepended to all messages- Returns:
- the prefix
-
getString
public java.lang.String getString(java.lang.String resource)
Return the NLS string given the resource.- Parameters:
resource
- the given resource- Returns:
- a NLS string
-
getString
public java.lang.String getString(java.lang.String resource, java.lang.Object param)
Return the NLS string given the resource and a parameter.- Parameters:
resource
- the given resourceparam
- a parameter- Returns:
- a NLS strings
-
getString
public java.lang.String getString(java.lang.String resource, java.lang.Object param1, java.lang.Object param2)
Return the NLS string given the resource and two parameters- Parameters:
resource
- the given resourceparam1
- a parameterparam2
- a parameter- Returns:
- a NLS strings
-
getString
public java.lang.String getString(java.lang.String resource, java.lang.Object[] params)
Return the NLS string given the resource and an array of parameters- Parameters:
resource
- the given resourceparams
- an array of parameters- Returns:
- a NLS strings
-
close
public void close()
Close the output logger
-
logfine
public void logfine(java.lang.String msg)
Logs a message to the output stream.- Parameters:
msg
- The message to log.
-
logdebug
public void logdebug(java.lang.String msg)
Log a message with info level if the debug mode flag istrue
, otherwise an debug level message is logged. This is done for all used loggers.- Parameters:
msg
- the message to log
-
loginfo
public void loginfo(java.lang.String msg)
Log a message with info level. This is done for all used loggers.- Parameters:
msg
- the message to log
-
logwarn
public void logwarn(java.lang.String msg)
Log a message with warning level. This is done for all used loggers.- Parameters:
msg
- the message to log
-
logerror
public void logerror(java.lang.String msg)
Log a message with error level. This is done for all used loggers.- Parameters:
msg
- the message to log
-
logerror
public void logerror(java.lang.String msg, java.lang.Throwable error)
Log a message with error level with an additional Throwable object. This is done for all used loggers.- Parameters:
msg
- the message to logerror
- the Throwable to be logged
-
logfatal
public void logfatal(java.lang.String msg)
Log a message with fatal level. This is done for all used loggers.- Parameters:
msg
- the message to log
-
fine
public void fine(java.lang.String res)
Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource given.- Parameters:
res
- the resource used for the message
-
fine
public void fine(java.lang.String res, java.lang.Object param)
Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
fine
public void fine(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message
-
fine
public void fine(java.lang.String res, java.lang.Object[] params)
Log a message with debug level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the message
-
debug
public void debug(java.lang.String res)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource given.- Parameters:
res
- the resource used for the message
-
debug
public void debug(java.lang.String res, java.lang.Object param)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
debug
public void debug(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message
-
debug
public void debug(java.lang.String res, java.lang.Object[] params)
Log a message with debug level if the debug mode flag istrue
, otherwise an info level message is logged. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the message
-
info
public void info(java.lang.String res)
Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource.- Parameters:
res
- the resource used for the message
-
info
public void info(java.lang.String res, java.lang.Object param)
Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
info
public void info(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message
-
info
public void info(java.lang.String res, java.lang.Object[] params)
Log a message with info level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the message
-
warn
public void warn(java.lang.String res)
Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource.- Parameters:
res
- the resource used for the message
-
warn
public void warn(java.lang.String res, java.lang.Object param)
Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
warn
public void warn(java.lang.String res, java.lang.Object param1, java.lang.Object param2)
Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message
-
warn
public void warn(java.lang.String res, java.lang.Object[] params)
Log a message with warning level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the message
-
error
public void error(java.lang.String res)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource.- Parameters:
res
- the resource used for the message
-
error
public void error(java.lang.String res, java.lang.Throwable error)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a Throwable object.- Parameters:
res
- the resource used for the messageerror
- the Throwable to be logged
-
error
public void error(java.lang.String res, java.lang.String param)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
error
public void error(java.lang.String res, java.lang.Object param, java.lang.Throwable error)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter and a Throwable object.- Parameters:
res
- the resource used for the messageparam
- a parameter for the messageerror
- the Throwable to be logged
-
error
public void error(java.lang.String res, java.lang.String param1, java.lang.String param2)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message
-
error
public void error(java.lang.String res, java.lang.Object[] params)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the message
-
error
public void error(java.lang.String res, java.lang.Object[] params, java.lang.Throwable error)
Log a message with error level. This is done for all used loggers. The message is a NLS string formed using the resource and includes array with parameters and a Throwable object.- Parameters:
res
- the resource used for the messageparams
- an array with parameters for the messageerror
- the Throwable to be logged
-
fatal
public void fatal(java.lang.String res)
Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource given.- Parameters:
res
- the resource used for the message
-
fatal
public void fatal(java.lang.String res, java.lang.Throwable err)
Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a Throwable object.- Parameters:
res
- the resource used for the messageerr
- the Throwable to be logged
-
fatal
public void fatal(java.lang.String res, java.lang.Object param)
Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message
-
fatal
public void fatal(java.lang.String res, java.lang.Object param, java.lang.Throwable err)
Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes a parameter and a Throwable object.- Parameters:
res
- the resource used for the messageparam
- a parameter for the messageerr
- the Throwable to be logged
-
fatal
public void fatal(java.lang.String res, java.lang.Object[] params)
Log a message with fatal level. This is done for all used loggers. The message is a NLS string formed using the resource and includes the given parameters.- Parameters:
res
- the resource used for the messageparams
- parameters for the message
-
log
public void log(java.lang.String level, java.lang.String msg)
Log a message with the specified level. This is done for all used loggers.- Parameters:
level
- The level to use when loggingmsg
- The string to be logged
-
exception
public void exception(java.lang.String res) throws java.lang.Exception
Throws a new exception with a custom message. The message is a NLS string formed using the given resource.- Parameters:
res
- the resource used for the message- Throws:
java.lang.Exception
- the thrown exception
-
exception
public void exception(java.lang.String res, java.lang.Object param) throws java.lang.Exception
Throws a new exception with a custom message. The message is a NLS string formed using the given resource and an additional parameter.- Parameters:
res
- the resource used for the messageparam
- a parameter for the message- Throws:
java.lang.Exception
- the thrown exception
-
exception
public void exception(java.lang.String res, java.lang.Object param1, java.lang.Object param2) throws java.lang.Exception
Throws a new exception with a custom message. The message is a NLS string formed using the given resource and two additional parameters.- Parameters:
res
- the resource used for the messageparam1
- a parameter for the messageparam2
- a parameter for the message- Throws:
java.lang.Exception
- the thrown exception
-
exception
public void exception(java.lang.String res, java.lang.Object[] params) throws java.lang.Exception
Throws a new exception with a custom message. The message is a NLS string formed using the given resource and an array of additional parameters.- Parameters:
res
- the resource used for the messageparams
- parameters for the message- Throws:
java.lang.Exception
- the thrown exception
-
dumpEntry
public void dumpEntry(Entry e)
Dumps a formatted message to the logfile from the contents of an Entry- Parameters:
e
- The entry to dump- See Also:
dump(java.lang.Object)
-
dump
public void dump(java.lang.Object o)
This methods dumps an Object to the log file.- Parameters:
o
- The entry to dump- See Also:
dumpEntry(com.ibm.di.entry.Entry)
-
-