Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class Logger

java.lang.Object
  extended by net.java.sip.communicator.util.Logger

public class Logger
extends Object

Standard logging methods.

Author:
Emil Ivov

Method Summary
 void debug(Object msg)
          Log a DEBUG message.
 void debug(Object msg, Throwable t)
          Log a message, with associated Throwable information.
 void error(Object msg)
          Log a ERROR message.
 void error(Object msg, Throwable t)
          Log a message, with associated Throwable information.
 void fatal(Object msg)
          Log a FATAL message.
 void fatal(Object msg, Throwable t)
          Log a message, with associated Throwable information.
static Logger getLogger(Class<?> clazz)
          Find or create a logger for the specified class.
static Logger getLogger(String name)
          Find or create a logger for a named subsystem.
 void info(Object msg)
          Log a INFO message.
 void info(Object msg, Throwable t)
          Log a message, with associated Throwable information.
 boolean isDebugEnabled()
          Check if a message with a DEBUG level would actually be logged by this logger.
 boolean isInfoEnabled()
          Check if a message with an INFO level would actually be logged by this logger.
 boolean isTraceEnabled()
          Check if a message with a TRACE level would actually be logged by this logger.
 void logEntry()
          Logs an entry in the calling method.
 void logExit()
          Logs exiting the calling method
 void reset()
          Reinitialize the logging properties and reread the logging configuration.
 void setLevelAll()
          Set logging level for all handlers to ALL (allow all log messages)
 void setLevelDebug()
          Set logging level for all handlers to DEBUG
 void setLevelError()
          Set logging level for all handlers to ERROR
 void setLevelFatal()
          Set logging level for all handlers to FATAL
 void setLevelInfo()
          Set logging level for all handlers to INFO
 void setLevelOff()
          Set logging level for all handlers to OFF (allow no log messages)
 void setLevelTrace()
          Set logging level for all handlers to TRACE
 void setLevelWarn()
          Set logging level for all handlers to WARNING
 void trace(Object msg)
          Log a TRACE message.
 void trace(Object msg, Throwable t)
          Log a message, with associated Throwable information.
 void warn(Object msg)
          Log a WARN message.
 void warn(Object msg, Throwable t)
          Log a message, with associated Throwable information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogger

public static Logger getLogger(Class<?> clazz)
                        throws NullPointerException
Find or create a logger for the specified class. If a logger has already been created for that class it is returned. Otherwise a new logger is created.

If a new logger is created its log level will be configured based on the logging configuration and it will be configured to also send logging output to its parent's handlers.

Parameters:
clazz - The creating class.

Returns:
a suitable Logger
Throws:
NullPointerException - if the name is null.

getLogger

public static Logger getLogger(String name)
                        throws NullPointerException
Find or create a logger for a named subsystem. If a logger has already been created with the given name it is returned. Otherwise a new logger is created.

If a new logger is created its log level will be configured based on the logging configuration and it will be configured to also send logging output to its parent's handlers.

Parameters:
name - A name for the logger. This should be a dot-separated name and should normally be based on the class name of the creator, such as "net.java.sip.communicator.MyFunnyClass"

Returns:
a suitable Logger
Throws:
NullPointerException - if the name is null.

logEntry

public void logEntry()
Logs an entry in the calling method.


logExit

public void logExit()
Logs exiting the calling method


isTraceEnabled

public boolean isTraceEnabled()
Check if a message with a TRACE level would actually be logged by this logger.

Returns:
true if the TRACE level is currently being logged

trace

public void trace(Object msg)
Log a TRACE message.

If the logger is currently enabled for the TRACE message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

trace

public void trace(Object msg,
                  Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

isDebugEnabled

public boolean isDebugEnabled()
Check if a message with a DEBUG level would actually be logged by this logger.

Returns:
true if the DEBUG level is currently being logged

debug

public void debug(Object msg)
Log a DEBUG message.

If the logger is currently enabled for the DEBUG message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

debug

public void debug(Object msg,
                  Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

isInfoEnabled

public boolean isInfoEnabled()
Check if a message with an INFO level would actually be logged by this logger.

Returns:
true if the INFO level is currently being logged

info

public void info(Object msg)
Log a INFO message.

If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

info

public void info(Object msg,
                 Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

warn

public void warn(Object msg)
Log a WARN message.

If the logger is currently enabled for the WARN message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

warn

public void warn(Object msg,
                 Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

error

public void error(Object msg)
Log a ERROR message.

If the logger is currently enabled for the ERROR message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

error

public void error(Object msg,
                  Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

fatal

public void fatal(Object msg)
Log a FATAL message.

If the logger is currently enabled for the FATAL message level then the given message is forwarded to all the registered output Handler objects.

Parameters:
msg - The message to log

fatal

public void fatal(Object msg,
                  Throwable t)
Log a message, with associated Throwable information.

Parameters:
msg - The message to log
t - Throwable associated with log message.

setLevelFatal

public void setLevelFatal()
Set logging level for all handlers to FATAL


setLevelError

public void setLevelError()
Set logging level for all handlers to ERROR


setLevelWarn

public void setLevelWarn()
Set logging level for all handlers to WARNING


setLevelInfo

public void setLevelInfo()
Set logging level for all handlers to INFO


setLevelDebug

public void setLevelDebug()
Set logging level for all handlers to DEBUG


setLevelTrace

public void setLevelTrace()
Set logging level for all handlers to TRACE


setLevelAll

public void setLevelAll()
Set logging level for all handlers to ALL (allow all log messages)


setLevelOff

public void setLevelOff()
Set logging level for all handlers to OFF (allow no log messages)


reset

public void reset()
Reinitialize the logging properties and reread the logging configuration.

The same rules are used for locating the configuration properties as are used at startup. So if the properties containing the log dir locations have changed, we would read the new configuration.


Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.