Logger (Jasper Internal API Documentation)
Keywords: org.apache.jasper.logging.Logger class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.jasper.logging
Class Logger

    java.lang.Object
      org.apache.jasper.logging.Logger

Direct Known Subclasses:
  DefaultLogger, JasperLogger

public abstract class Logger
extends java.lang.Object

Interface for a logging object. A logging object provides mechanism for logging errors and messages that are of interest to someone who is trying to monitor the system.

Since:
  Tomcat 3.1
Author:
  Anil Vijendran (akv@eng.sun.com), Alex Chaffee (alex@jguru.com)

Nested Class Summary
`static class` | `Logger.Helper` Wrapper for Logger.

Field Summary
`protected boolean` | `custom`
`static int` | `DEBUG`
`protected static Logger` | `defaultLogger`
`protected static java.io.Writer` | `defaultSink`
`static int` | `ERROR`
`static int` | `FATAL` Verbosity level codes.
`static int` | `INFORMATION`
`protected static java.util.Hashtable` | `loggers`
`protected java.lang.String` | `name`
`protected java.io.Writer` | `sink`
`protected boolean` | `timestamp` Should we timestamp this log at all?
`protected java.lang.String` | `timestampFormat` The timestamp format string, default is "yyyy-MM-dd hh:mm:ss"
`protected java.text.DateFormat` | `timestampFormatter`
`protected boolean` | `timestampRaw` true = The timestamp format is raw msec-since-epoch false = The timestamp format is a custom string to pass to SimpleDateFormat
`static int` | `WARNING`

Constructor Summary
`Logger()`

Method Summary
`static boolean` | `canIgnore(java.lang.Throwable t)` General purpose nasty hack to determine if an exception can be safely ignored -- specifically, if it's an IOException or SocketException that is thrown in the normal course of a socket closing halfway through a connection, or if it's a weird unknown type of exception.
`void` | `close()` Close the log.
`abstract void` | `flush()` Flush the log.
`protected java.lang.String` | `formatTimestamp(long msec)`
`protected void` | `formatTimestamp(long msec, java.lang.StringBuffer buf)`
`static Logger` | `getDefaultLogger()` Get the logger that prints to the default sink (usu.
`static Logger` | `getLogger(java.lang.String name)`
`static java.util.Enumeration` | `getLoggerNames()`
`java.lang.String` | `getName()` Get name of this log channel.
`java.lang.String` | `getPath()`
`java.lang.String` | `getTimestampFormat()`
`int` | `getVerbosityLevel()` Get the current verbosity level.
`boolean` | `isOpen()` Is this Log usable?
`boolean` | `isTimestamp()`
`void` | `log(java.lang.String message)` Prints the log message at the "default" log level: INFORMATION
`void` | `log(java.lang.String message, int verbosityLevel)` Prints the log message.
`void` | `log(java.lang.String message, java.lang.Throwable t)` Prints log message and stack trace, with verbosityLevel ERROR.
`void` | `log(java.lang.String message, java.lang.Throwable t, int verbosityLevel)` Prints log message and stack trace.
`boolean` | `matchVerbosityLevel(int verbosityLevel)`
`void` | `open()` Open the log - will create the log file and all the parent directories.
`static void` | `putLogger(Logger logger)`
`protected abstract void` | `realLog(java.lang.String message)` Subclasses implement these methods which are called by the log(..) methods internally.
`protected abstract void` | `realLog(java.lang.String message, java.lang.Throwable t)` Subclasses implement these methods which are called by the log(..) methods internally.
`static void` | `removeLogger(Logger logger)`
`void` | `setCustomOutput(java.lang.String value)`
`static void` | `setDefaultSink(java.io.Writer w)` Set the default output stream that is used by all logging channels.
`void` | `setName(java.lang.String name)` Set name of this log channel.
`void` | `setPath(java.lang.String path)` Set the path name for the log output file.
`void` | `setTimestamp(java.lang.String value)` Do we need to time stamp this or not?
`void` | `setTimestampFormat(java.lang.String value)` Set the format to be used for the timestamp, assuming that timestamping is enabled.
`void` | `setVerbosityLevel(int level)` Set the verbosity level for this logger.
`void` | `setVerbosityLevel(java.lang.String level)` Set the verbosity level for this logger.
`static java.lang.String` | `throwableToString(java.lang.Throwable t)` Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException if applicable TODO: JDBCException too
`static java.lang.String` | `throwableToString(java.lang.Throwable t, java.lang.String rootcause)` Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException or SQLException if applicable
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### FATAL

    public static final int FATAL

  Verbosity level codes.

  See Also:
    Constant Field Values

### ERROR

    public static final int ERROR

See Also:
  Constant Field Values

### WARNING

    public static final int WARNING

See Also:
  Constant Field Values

### INFORMATION

    public static final int INFORMATION

See Also:
  Constant Field Values

### DEBUG

    public static final int DEBUG

See Also:
  Constant Field Values

### defaultSink

    protected static java.io.Writer defaultSink

### loggers

    protected static java.util.Hashtable loggers

### defaultLogger

    protected static Logger defaultLogger

### custom

    protected boolean custom

### sink

    protected java.io.Writer sink

### name

    protected java.lang.String name

### timestamp

    protected boolean timestamp

  Should we timestamp this log at all?

### timestampRaw

    protected boolean timestampRaw

  true = The timestamp format is raw msec-since-epoch
  false = The timestamp format is a custom string to pass to SimpleDateFormat

### timestampFormat

    protected java.lang.String timestampFormat

  The timestamp format string, default is "yyyy-MM-dd hh:mm:ss"

### timestampFormatter

    protected java.text.DateFormat timestampFormatter

Constructor Detail

### Logger

    public Logger()

Method Detail

### setDefaultSink

    public static void setDefaultSink(java.io.Writer w)

  Set the default output stream that is used by all logging channels.

  Parameters:
    `w` - the default output stream.

### getLogger

    public static Logger getLogger(java.lang.String name)

### getDefaultLogger

    public static Logger getDefaultLogger()

  Get the logger that prints to the default sink (usu. System.err)

### getLoggerNames

    public static java.util.Enumeration getLoggerNames()

### putLogger

    public static void putLogger(Logger logger)

### removeLogger

    public static void removeLogger(Logger logger)

### throwableToString

    public static java.lang.String throwableToString(java.lang.Throwable t)

  Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException if applicable TODO: JDBCException too

  Parameters:
    `t` - any Throwable, or ServletException, or null

### throwableToString

    public static java.lang.String throwableToString(java.lang.Throwable t,
                                                     java.lang.String rootcause)

  Converts a Throwable to a printable stack trace, including the nested root cause for a ServletException or JasperException or SQLException if applicable

  Parameters:
    `t` - any Throwable, or ServletException, or null
    `rootcause` - localized string equivalent of "Root Cause"

### canIgnore

    public static boolean canIgnore(java.lang.Throwable t)

  General purpose nasty hack to determine if an exception can be safely ignored -- specifically, if it's an IOException or SocketException that is thrown in the normal course of a socket closing halfway through a connection, or if it's a weird unknown type of exception. This is an intractable problem, and this is a bad solution, but at least it's centralized.

### isOpen

    public boolean isOpen()

  Is this Log usable?

### log

    public final void log(java.lang.String message)

  Prints the log message at the "default" log level: INFORMATION

  Parameters:
    `message` - the message to log.

### log

    public final void log(java.lang.String message,
                          int verbosityLevel)

  Prints the log message.

  Parameters:
    `message` - the message to log.
    `verbosityLevel` - what type of message is this? (WARNING/DEBUG/INFO etc)

### log

    public final void log(java.lang.String message,
                          java.lang.Throwable t)

  Prints log message and stack trace, with verbosityLevel ERROR. This makes the assumption that throwables are exceptions which are errors by nature; if you disagree, you can always call log(msg, t, Logger.INFORMATION) or whatever.

  Parameters:
    `message` - the message to log.
    `t` - the exception that was thrown.

### log

    public final void log(java.lang.String message,
                          java.lang.Throwable t,
                          int verbosityLevel)

  Prints log message and stack trace.

  Parameters:
    `message` - the message to log.
    `t` - the exception that was thrown.
    `verbosityLevel` - what type of message is this? (WARNING/DEBUG/INFO etc)

### matchVerbosityLevel

    public boolean matchVerbosityLevel(int verbosityLevel)

### realLog

    protected abstract void realLog(java.lang.String message)

  Subclasses implement these methods which are called by the log(..) methods internally.

  Parameters:
    `message` - the message to log.

### realLog

    protected abstract void realLog(java.lang.String message,
                                    java.lang.Throwable t)

  Subclasses implement these methods which are called by the log(..) methods internally.

  Parameters:
    `message` - the message to log.
    `t` - the exception that was thrown.

### flush

    public abstract void flush()

  Flush the log.

### close

    public void close()

  Close the log.

### getName

    public java.lang.String getName()

  Get name of this log channel.

### setName

    public void setName(java.lang.String name)

  Set name of this log channel.

  Parameters:
    `name` - Name of this logger.

### setPath

    public void setPath(java.lang.String path)

  Set the path name for the log output file.

  Parameters:
    `path` - The path to the log file.

### getPath

    public java.lang.String getPath()

### toString

    public java.lang.String toString()

### open

    public void open()

  Open the log - will create the log file and all the parent directories. You must open the logger before use, or it will write to System.err

### setVerbosityLevel

    public void setVerbosityLevel(java.lang.String level)

  Set the verbosity level for this logger. This controls how the logs will be filtered.

  Parameters:
    `level` - one of the verbosity level strings.

### setVerbosityLevel

    public void setVerbosityLevel(int level)

  Set the verbosity level for this logger. This controls how the logs will be filtered.

  Parameters:
    `level` - one of the verbosity level codes.

### getVerbosityLevel

    public int getVerbosityLevel()

  Get the current verbosity level.

### setTimestamp

    public void setTimestamp(java.lang.String value)

  Do we need to time stamp this or not?

  Parameters:
    `value` - "yes/no" or "true/false"

### isTimestamp

    public boolean isTimestamp()

### setTimestampFormat

    public void setTimestampFormat(java.lang.String value)

  Set the format to be used for the timestamp, assuming that timestamping is enabled. @see java.text.SimpleDateFormat. Default = "yyyy-MM-dd hh:mm:ss". Special case: "msec" => raw number of msec since epoch, very efficient but not user-friendly

### getTimestampFormat

    public java.lang.String getTimestampFormat()

### setCustomOutput

    public void setCustomOutput(java.lang.String value)

### formatTimestamp

    protected java.lang.String formatTimestamp(long msec)

### formatTimestamp

    protected void formatTimestamp(long msec,
                                   java.lang.StringBuffer buf)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 Apache Software Foundation. All Rights Reserved.