org.apache.commons.ssl
Class LogWrapper

java.lang.Object
  extended byorg.apache.commons.ssl.LogWrapper

public class LogWrapper
extends java.lang.Object

LogWrapper can be used for situations where log4j might not be available on the classpath. It presents the most basic and critical components of the log4j API, and passes all log calls through to log4j if possible. If log4j is not available, logging is sent to standard-out by default.

This default logging to standard-out (which only occurs if log4j is NOT available) can be disabled or changed via the static setBackupStream() and setBackupLogFile() methods.

Since:
3-Aug-2006
Author:
Credit Union Central of British Columbia, www.cucbc.com, juliusdavies@cucbc.com

Field Summary
static boolean log4j
          true if log4j is available
 
Method Summary
 void debug(java.lang.Object o)
           
 void debug(java.lang.Object o, java.lang.Throwable t)
           
 void error(java.lang.Object o)
           
 void error(java.lang.Object o, java.lang.Throwable t)
           
 void fatal(java.lang.Object o)
           
 void fatal(java.lang.Object o, java.lang.Throwable t)
           
static java.io.OutputStream getBackupStream()
          Get the PrintStream we're logging to if log4j is not available.
 java.lang.Object getLog4jLogger()
           
static LogWrapper getLogger(java.lang.Class c)
           
static LogWrapper getLogger(java.lang.String s)
           
 void info(java.lang.Object o)
           
 void info(java.lang.Object o, java.lang.Throwable t)
           
 boolean isDebugEnabled()
           
 boolean isInfoEnabled()
           
static boolean isLog4jAvailable()
           
static void setBackupLogFile(java.lang.String f)
          Set file to log to if log4j is not available.
static void setBackupStream(java.io.OutputStream os)
          Set PrintStream to log to if log4j is not available.
 void warn(java.lang.Object o)
           
 void warn(java.lang.Object o, java.lang.Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log4j

public static final boolean log4j
true if log4j is available

Method Detail

isLog4jAvailable

public static boolean isLog4jAvailable()

getLogger

public static LogWrapper getLogger(java.lang.Class c)

getLogger

public static LogWrapper getLogger(java.lang.String s)

debug

public void debug(java.lang.Object o)

debug

public void debug(java.lang.Object o,
                  java.lang.Throwable t)

info

public void info(java.lang.Object o)

info

public void info(java.lang.Object o,
                 java.lang.Throwable t)

warn

public void warn(java.lang.Object o)

warn

public void warn(java.lang.Object o,
                 java.lang.Throwable t)

error

public void error(java.lang.Object o)

error

public void error(java.lang.Object o,
                  java.lang.Throwable t)

fatal

public void fatal(java.lang.Object o)

fatal

public void fatal(java.lang.Object o,
                  java.lang.Throwable t)

isDebugEnabled

public boolean isDebugEnabled()

isInfoEnabled

public boolean isInfoEnabled()

getLog4jLogger

public java.lang.Object getLog4jLogger()

setBackupLogFile

public static void setBackupLogFile(java.lang.String f)
                             throws java.io.IOException
Set file to log to if log4j is not available.

Parameters:
f - path to use for backup log file (if log4j not available)
Throws:
java.io.IOException - if we can't write to the given path

setBackupStream

public static void setBackupStream(java.io.OutputStream os)
Set PrintStream to log to if log4j is not available. Set to null to disable. Default value is System.out.

Parameters:
os - outputstream to use for backup logging (if log4j not available)

getBackupStream

public static java.io.OutputStream getBackupStream()
Get the PrintStream we're logging to if log4j is not available.

Returns:
OutputStream we're using as our log4j replacement.


Copyright © 2011. All Rights Reserved.