Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


oracle.ldap.util
Class Logger

java.lang.Object
  extended by oracle.ldap.util.Logger


public class Logger
extends java.lang.Object

A logger utility to log the error messages.

Since:
9.4 and iAS 9.0.4

Field Summary
static int ALL_TYPES
          Messages of all types.
static int DEBUG
          Debug Message
static int ERROR
          Error Message
static int INFO
          Informational Message
static int WARNING
          Warning Message

 

Constructor Summary
Logger(java.io.OutputStream outS, int severity)
          Constructs a Logger object which provide methods to the log message to the specified output stream.
Logger(java.io.OutputStream outS, int severity, boolean xmlLog)
          Constructs a Logger object which provide methods to the log message to the specified output stream as XML content.
Logger(java.lang.String fileName, int severity, boolean append)
          Constructs a Logger object which will provide the methods to log the messages to the specified file.
Logger(java.lang.String fileName, int severity, boolean append, boolean xmlLog)
          Constructs a Logger object which provide methods to the log messages as XML content to the specified file.

 

Method Summary
 void close()
          Closes the writer streams.
 void log(java.lang.Exception ex, int severity)
          Logs the Exception object to a file.
 void log(java.lang.Exception ex, int severity, boolean console)
          logs the Exception object both to a file and console,
 void log(java.lang.String message, int severity)
          Logs the given message to a file if logging of the specified message category is enabled.
 void log(java.lang.String message, int severity, boolean console)
          Logs the specified message if logging of the specified category is enabled and if writing to console is set to true then the message is also written to cosole.
 void setSeverity(int severity)
          Set the severity of the log messages that needs to be logged.
 void unsetSeverity(int severity)
          unsets the severity of the log messages.

 

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

 

Field Detail

INFO

public static final int INFO
Informational Message
See Also:
Constant Field Values

WARNING

public static final int WARNING
Warning Message
See Also:
Constant Field Values

DEBUG

public static final int DEBUG
Debug Message
See Also:
Constant Field Values

ERROR

public static final int ERROR
Error Message
See Also:
Constant Field Values

ALL_TYPES

public static final int ALL_TYPES
Messages of all types.
See Also:
Constant Field Values

Constructor Detail

Logger

public Logger(java.lang.String fileName,
              int severity,
              boolean append)
       throws LogException
Constructs a Logger object which will provide the methods to log the messages to the specified file. To specify the severity of the messages that needs to be logged, use one of the following Logger.INFO, Logger.WARNING, Logger.ERROR or Logger.DEBUG

 e.x code 

    // log only ERROR and WARNING messages, rest will be ignored.
    Logger logger = new Logger("LogFile.log",Logger.ERROR | Logger.WARNING
                                        false);
    ....
    ...
    logger.log("Unable to establish a connection", Logger.ERROR);
    
    this will result in writing to the log file the above message as
    ERROR: [Timestamp] Unable to establish a connection
 
Parameters:
fileName - name of the file to which log message needs to written.
severity - specifies the message category that needs to be logged.
append - if true, then data will be written to the end of the file.
Throws:
LogException - if an I/O error occurs.

Logger

public Logger(java.lang.String fileName,
              int severity,
              boolean append,
              boolean xmlLog)
       throws LogException
Constructs a Logger object which provide methods to the log messages as XML content to the specified file.
 e.x code 

    // log only ERROR and WARNING messages, rest will be ignored.

    Logger logger = new Logger("LogFile.xml", Logger.ERROR|Logger.WARNING,
                                              false, true);
    ....
    ...
    logger.log("Unable to establish a connection", Logger.ERROR);

    logger.close();
    
    this will result in writing to the log file the above message. The
    contents of the file is as follows

    <Log Timestamp="21 May 2002 09:45:45:34">
       <Error Timestamp="21 May 2002 09:45:45:34">
          Unable to establish a connection
       </Error>
       <Info Timestamp="21 May 2002 09:45:50:04">
          ...  
       </Info>
          ......
       <Warning>
          ......
       </Warning>
    </Log>

 
Parameters:
fileName - name of the file to which log message needs to written.
severity - specifies the message category that needs to be logged.
append - if true, then data will be written to the end of the file.
Throws:
LogException - if an I/O error occurs.

Logger

public Logger(java.io.OutputStream outS,
              int severity)
       throws LogException
Constructs a Logger object which provide methods to the log message to the specified output stream.
Parameters:
outS - the output stream to which the log message needs to written.
severity - specifies the message category that needs to be logged.
Throws:
LogException - if an I/O error occurs.

Logger

public Logger(java.io.OutputStream outS,
              int severity,
              boolean xmlLog)
       throws LogException
Constructs a Logger object which provide methods to the log message to the specified output stream as XML content.
Parameters:
outS - the output stream to which the log message needs to written.
severity - specifies the message category that needs to be logged.
xmlLog - if true log messages will be written as XML content.
Throws:
LogException - if an I/O error occurs.

Method Detail

setSeverity

public void setSeverity(int severity)
Set the severity of the log messages that needs to be logged. ex. logger.setSeverity(Logger.DEBUG | Logger.ERROR) the above call instructs the logger to log DEBUG and ERROR messages.
Parameters:
severity - the message category that needs to be logged.

unsetSeverity

public void unsetSeverity(int severity)
unsets the severity of the log messages. In other words this methods specifies not to log the message of the specified category. ex. logger.unsetSeverity(Logger.DEBUG | Logger.ERROR) the above call instructs the logger not to log DEBUG and ERROR messages.
Parameters:
severity - the message category that needs to be logged.

log

public void log(java.lang.String message,
                int severity)
Logs the given message to a file if logging of the specified message category is enabled.
Parameters:
message - to be logged
severity - of the message.

log

public void log(java.lang.String message,
                int severity,
                boolean console)
Logs the specified message if logging of the specified category is enabled and if writing to console is set to true then the message is also written to cosole.
Parameters:
message - to be logged
severity - of the message.

log

public void log(java.lang.Exception ex,
                int severity)
Logs the Exception object to a file.
Parameters:
message - to be logged
severity - of the message.

log

public void log(java.lang.Exception ex,
                int severity,
                boolean console)
logs the Exception object both to a file and console,
Parameters:
message - to be logged
severity - of the message.

close

public void close()
Closes the writer streams.

Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


Copyright © 1999, 2009 Oracle. All Rights Reserved.