ariba.util.log
Class LogManager

java.lang.Object
  extended by org.apache.log4j.LogManager
      extended by ariba.util.log.LogManager

public class LogManager
extends org.apache.log4j.LogManager

Helper class with utility methods for creation and access of common appenders, the means to archive log files, and stamdard "lifecycle" methods (setupArguments, processArguments, startup, shutdown, etc.).


Field Summary
static java.lang.String CommonNameForConsole
          The common name for the console listener.
static java.lang.String CommonNameForFile
          The common name for the file in Parameters.table.
static java.lang.String CommonNameForInspector
          The common name for the Inspector log in Parameters.table.
static java.lang.String DefaultLogArchive
          The default directory where archived log files will be stored.
static java.lang.String DefaultLogDirectory
          The default directory where log files will be stored.
static java.lang.String LogFileSuffix
          The standard log filename suffix including extension.
static java.lang.String OptionLogToConsole
          The command line-style option name for the console logging switch.
 
Fields inherited from class org.apache.log4j.LogManager
CONFIGURATOR_CLASS_KEY, DEFAULT_CONFIGURATION_FILE, DEFAULT_CONFIGURATION_KEY, DEFAULT_INIT_OVERRIDE_KEY
 
Constructor Summary
LogManager()
           
 
Method Summary
static void addWarningLogHandler(org.apache.log4j.Appender appender)
          Adds an appender to the list of warning log handlers.
static void archiveLogFiles(Parameters params)
          Archives registered logging files.
static org.apache.log4j.Appender createConsoleAppender()
          Creates a new appender that writes to standard out using the default layout.
static org.apache.log4j.Appender createFileAppender(java.lang.String prefix)
          Creates a new appender that writes to the named file using the archiving options.
static void flush()
          ToDo: seemingly vestigial method with a handful of callers Should probably remove as it does nothing anyway.
static java.lang.String getArchiveDirectoryName()
          Return the directory where archive log files will be stored.
static org.apache.log4j.Appender getCommonConsoleAppender()
          Return the shared standard out appender, if one has been defined.
static org.apache.log4j.Appender getCommonFileAppender()
          Return the primary file appender, if one has been defined.
static java.util.List getCurrentLoggerList()
          Replace the log4j functionality to make sure we only return our Loggers.
static java.util.Enumeration getCurrentLoggers()
          Override the log4j method to make sure we only return our Loggers.
static java.lang.String getDirectoryName()
          Return the directory where active log files will be stored.
static java.lang.String getEncoding()
          Return the standard encoding method for log files.
static boolean loggingInitialized()
          ToDo: seemingly vestigial method with a handful of callers Should probably remove--it's hardcoded to return true.
 long loggingInitializedAt()
          Accessor for timestamp when logging was initialized - pretty close to start of process.
static void processArguments(ArgumentParser arguments)
          Processing stage of option argument parsing.
static void removeDefaultConsole()
          Deactivates the DefaultConsole appender that is defined as part of the static configuration of log4j.
static void removeWarningLogHandler(org.apache.log4j.Appender appender)
          Removes an appender from the list of warning log handlers.
static void setArchiveDirectoryName(java.lang.String archiveDir)
          Establish the directory where archive log files will be stored.
static void setCommonConsoleAppender(org.apache.log4j.Appender console, boolean makeRoot)
          Set the shared standard out appender.
static void setCommonFileAppender(org.apache.log4j.Appender file, boolean makeRoot)
          Set the primary file appender.
static void setDirectoryName(java.lang.String dir)
          Establish the directory where active log files will be stored.
static void setEncoding(java.lang.String enc)
          Set the standard encoding method for log files.
static void setupArguments(ArgumentParser arguments)
          First stage of option argument parsing.
static void shutdown()
          Indicates the controlling server or command line tool has completed.
static void startup()
          Indicates the controlling server or command line tool has completed initialization (of parameters, etc.) and is ready to put the LogManager in "running" mode.
static AsyncAppender wrapInAsyncAppender(org.apache.log4j.Appender appender)
          Wrap an appender so it works asynchronously, and will buffer logging events.
 
Methods inherited from class org.apache.log4j.LogManager
exists, getLogger, getLogger, getLogger, getLoggerRepository, getRootLogger, resetConfiguration, setRepositorySelector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LogFileSuffix

public static final java.lang.String LogFileSuffix
The standard log filename suffix including extension.

See Also:
Constant Field Values

OptionLogToConsole

public static final java.lang.String OptionLogToConsole
The command line-style option name for the console logging switch.

See Also:
logToConsole, Constant Field Values

CommonNameForFile

public static final java.lang.String CommonNameForFile
The common name for the file in Parameters.table.

See Also:
Constant Field Values

CommonNameForConsole

public static final java.lang.String CommonNameForConsole
The common name for the console listener.

See Also:
Constant Field Values

CommonNameForInspector

public static final java.lang.String CommonNameForInspector
The common name for the Inspector log in Parameters.table.

See Also:
Constant Field Values

DefaultLogDirectory

public static final java.lang.String DefaultLogDirectory
The default directory where log files will be stored.

See Also:
Constant Field Values

DefaultLogArchive

public static final java.lang.String DefaultLogArchive
The default directory where archived log files will be stored.

Constructor Detail

LogManager

public LogManager()
Method Detail

loggingInitializedAt

public long loggingInitializedAt()
Accessor for timestamp when logging was initialized - pretty close to start of process.


getCurrentLoggers

public static java.util.Enumeration getCurrentLoggers()
Override the log4j method to make sure we only return our Loggers. Curse you, Apache Commons!


getCurrentLoggerList

public static java.util.List getCurrentLoggerList()
Replace the log4j functionality to make sure we only return our Loggers. Curse you, Apache Commons!


setDirectoryName

public static void setDirectoryName(java.lang.String dir)
Establish the directory where active log files will be stored.

Parameters:
dir - the name (not a path) of the directory

getDirectoryName

public static java.lang.String getDirectoryName()
Return the directory where active log files will be stored.

Returns:
String the name (not a path) of the directory

setArchiveDirectoryName

public static void setArchiveDirectoryName(java.lang.String archiveDir)
Establish the directory where archive log files will be stored.

Parameters:
archiveDir - the name (not a path) of the directory

getArchiveDirectoryName

public static java.lang.String getArchiveDirectoryName()
Return the directory where archive log files will be stored.

Returns:
String the name (not a path) of the archive directory

removeDefaultConsole

public static void removeDefaultConsole()
Deactivates the DefaultConsole appender that is defined as part of the static configuration of log4j.


createConsoleAppender

public static org.apache.log4j.Appender createConsoleAppender()
Creates a new appender that writes to standard out using the default layout.

Returns:
Appender a new appender that writes to standard out

getCommonConsoleAppender

public static org.apache.log4j.Appender getCommonConsoleAppender()
Return the shared standard out appender, if one has been defined.

Returns:
Appender null or the shared standard out appender

setCommonConsoleAppender

public static void setCommonConsoleAppender(org.apache.log4j.Appender console,
                                            boolean makeRoot)
Set the shared standard out appender.

Parameters:
console - the shared standard out appender to set
makeRoot - if true add this appender to the root logger

createFileAppender

public static org.apache.log4j.Appender createFileAppender(java.lang.String prefix)
Creates a new appender that writes to the named file using the archiving options.

Parameters:
prefix - the filename prefix
Returns:
Appender a new appender that writes to a file named: prefix + standard suffix
See Also:
LogFileSuffix

getCommonFileAppender

public static org.apache.log4j.Appender getCommonFileAppender()
Return the primary file appender, if one has been defined.

Returns:
Appender null or the primary file appender

setCommonFileAppender

public static void setCommonFileAppender(org.apache.log4j.Appender file,
                                         boolean makeRoot)
Set the primary file appender.

Parameters:
file - the primary file appender to set
makeRoot - if true add this appender to the root logger

addWarningLogHandler

public static void addWarningLogHandler(org.apache.log4j.Appender appender)
Adds an appender to the list of warning log handlers. Warning log handlers are the special appenders which print the log messages when the level is warning or lower, even if the logger has not been configured for these appenders.

Parameters:
appender - the appender to add.

removeWarningLogHandler

public static void removeWarningLogHandler(org.apache.log4j.Appender appender)
Removes an appender from the list of warning log handlers. Warning log handlers are the special appenders that print the log messages when the level is warning or lower, even if the logger has not been configured for these appenders.

Parameters:
appender - the appender to remove.

wrapInAsyncAppender

public static final AsyncAppender wrapInAsyncAppender(org.apache.log4j.Appender appender)
Wrap an appender so it works asynchronously, and will buffer logging events.

Parameters:
appender - the appender to be made asynchronous.

setEncoding

public static void setEncoding(java.lang.String enc)
Set the standard encoding method for log files.

Parameters:
enc - the standard encoding method

getEncoding

public static java.lang.String getEncoding()
Return the standard encoding method for log files.

Returns:
String the standard encoding method

setupArguments

public static void setupArguments(ArgumentParser arguments)
First stage of option argument parsing. Used to indicate which options LogManager is interested in, what type their values are, and whether each option is mandatory or optional.

Parameters:
arguments - the source of the current command line arguments

processArguments

public static void processArguments(ArgumentParser arguments)
Processing stage of option argument parsing. Used to process the options LogManager is interested in.

Parameters:
arguments - the source of the current command line arguments

startup

public static void startup()
Indicates the controlling server or command line tool has completed initialization (of parameters, etc.) and is ready to put the LogManager in "running" mode.


archiveLogFiles

public static void archiveLogFiles(Parameters params)
Archives registered logging files.

See Also:
ArchivingAppender

flush

public static void flush()
ToDo: seemingly vestigial method with a handful of callers Should probably remove as it does nothing anyway.


shutdown

public static void shutdown()
Indicates the controlling server or command line tool has completed.


loggingInitialized

public static boolean loggingInitialized()
ToDo: seemingly vestigial method with a handful of callers Should probably remove--it's hardcoded to return true.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.