com.sun.ebxml.registry.util
Class Log

java.lang.Object
  |
  +--com.sun.ebxml.registry.util.Log

public class Log
extends java.lang.Object

Error and trace log implementation. A single log is implementated per process (e.g. Virtual Machine). This implementation uses a file based model. A separate file for each log category is supported.

Author:
Frank Richichi

Field Summary
static int ERROR
           
static int FIRST_CATEGORY
          Log categories are used to differentiate messages into separate files.
static int INFO
           
static int LAST_CATEGORY
           
static int TRACE
           
static int WARN
           
 
Method Summary
static void initialize(java.io.PrintWriter errorOut, java.io.PrintWriter traceOut, int level)
          Initialize log context.
static void initialize(java.lang.String logFileName, int level)
          Initialize log context.
static void initialize(java.lang.String errorFileName, java.lang.String traceFileName, int level, boolean append)
          Initialize log context.
static void print(int category, int msgLevel, java.lang.String msg)
          Only log msg if msgLevel is less than current logLevel or if ERROR.
static void printBuffer(int category, int msgLevel, java.util.Collection buffer, java.lang.String vName)
          Convenience utility for printing a buffer of objects.
static void printStackTrace(java.lang.Throwable t)
          Convenience utility for printing stack trace to error log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRST_CATEGORY

public static final int FIRST_CATEGORY
Log categories are used to differentiate messages into separate files. The various logs default to System.err and System.out if not set

See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

WARN

public static final int WARN
See Also:
Constant Field Values

INFO

public static final int INFO
See Also:
Constant Field Values

TRACE

public static final int TRACE
See Also:
Constant Field Values

LAST_CATEGORY

public static final int LAST_CATEGORY
See Also:
Constant Field Values
Method Detail

print

public static void print(int category,
                         int msgLevel,
                         java.lang.String msg)
Only log msg if msgLevel is less than current logLevel or if ERROR. Writes to a PrintWriter if initialized. Otherwise writes to System.out. Illegal category types are written to TRACE output.

Parameters:
category - set to INFO, ERROR, WARN, TRACE.
msg - text too write
msgLevel - a number from 0 to 10. Give rare important messages a low number and give numerous, not important messages a higher number.

printBuffer

public static void printBuffer(int category,
                               int msgLevel,
                               java.util.Collection buffer,
                               java.lang.String vName)
Convenience utility for printing a buffer of objects.


printStackTrace

public static void printStackTrace(java.lang.Throwable t)
Convenience utility for printing stack trace to error log. Prints to standard error if called before initialized.


initialize

public static void initialize(java.lang.String logFileName,
                              int level)
Initialize log context. [deprecated]. Here for backward compatibility. Takes a single name and generates error and trace files by adding an extension to it. stderr and stdout are used if none is specified. Defaults to overwrite file.

Parameters:
logFileName - basename for error and trace logs.
level - verbosity level

initialize

public static void initialize(java.lang.String errorFileName,
                              java.lang.String traceFileName,
                              int level,
                              boolean append)
Initialize log context. May be re-initialized. This method creates PrintWriter OR uses the System.err and System.out PrintStreams. This method is used for standalone operation. A preamble is used for output to a file. If System.err or System.out is used the preamble is not printed.

Parameters:
errorFileName - use stderr if errorFileName is null.
traceFileName - use stdout if traceFileName is null.
level - verbosity level
append - if true then append to end of file, otherwise overwrite

initialize

public static void initialize(java.io.PrintWriter errorOut,
                              java.io.PrintWriter traceOut,
                              int level)
Initialize log context. May be initialized only once.

Parameters:
errorOut - writer for stack trace and error
traceOut - use stdout if traceFileName is null.
level - verbosity level


Copyright © 2001-2003 OASIS. All Rights Reserved.