Search in sources :

Example 1 with LogMessageProviderBase

use of com.sun.identity.log.messageid.LogMessageProviderBase in project OpenAM by OpenRock.

the class AuthD method logIt.

////////////////////////////////////////////////////////////////
//  Other utilities
////////////////////////////////////////////////////////////////
/**
      * Writes a log record.
      *
      * @param s Array of data information for the log record.
      * @param type Type of log either <code>LOG_ERROR</code> or
      *        <code>LOG_ACCESS</code>.
      * @param messageName Message ID for the log record.
      * @param ssoProperties Single Sign On Properties to be written to the
      *        log record. If this is <code>null</code>, properties will be
      *        retrieved from administrator Single Sign On Token.
      */
public void logIt(String[] s, int type, String messageName, Hashtable ssoProperties) {
    if (logStatus && (s != null)) {
        try {
            LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Authentication");
            com.sun.identity.log.LogRecord lr = null;
            SSOToken ssot = AccessController.doPrivileged(AdminTokenAction.getInstance());
            if (ssoProperties == null) {
                lr = provider.createLogRecord(messageName, s, ssot);
            } else {
                lr = provider.createLogRecord(messageName, s, ssoProperties);
            }
            com.sun.identity.log.Logger logger;
            switch(type) {
                case LOG_ACCESS:
                    logger = (com.sun.identity.log.Logger) Logger.getLogger("amAuthentication.access");
                    logger.log(lr, ssot);
                    break;
                case LOG_ERROR:
                    logger = (com.sun.identity.log.Logger) Logger.getLogger("amAuthentication.error");
                    logger.log(lr, ssot);
                    break;
                default:
                    logger = (com.sun.identity.log.Logger) Logger.getLogger("amAuthentication.access");
                    logger.log(lr, ssot);
                    break;
            }
        } catch (IOException ex) {
            ex.printStackTrace();
            debug.error("Logging exception : " + ex.getMessage());
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Logger(com.sun.identity.log.Logger) LogMessageProviderBase(com.sun.identity.log.messageid.LogMessageProviderBase) IOException(java.io.IOException)

Example 2 with LogMessageProviderBase

use of com.sun.identity.log.messageid.LogMessageProviderBase in project OpenAM by OpenRock.

the class LogManagerUtil method logEndRecords.

/**
     *  Log a LogRecord indicating the end of logging to all opened files
     */
public static void logEndRecords() {
    if (lmgr != null) {
        try {
            SSOToken ssot = getLoggingSSOToken();
            LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Logging");
            String[] s = new String[1];
            Enumeration e = lmgr.getLoggerNames();
            com.sun.identity.log.LogRecord lr = null;
            while (e.hasMoreElements()) {
                String logger = (String) e.nextElement();
                if (logger.length() != 0 && !logger.equals("global")) {
                    Logger result = (Logger) Logger.getLogger(logger);
                    s[0] = logger;
                    lr = provider.createLogRecord(LogConstants.END_LOG_NAME, s, ssot);
                    result.log(lr, ssot);
                    result.flush();
                }
            }
        } catch (IOException ioex) {
        // can't do much here
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Enumeration(java.util.Enumeration) LogMessageProviderBase(com.sun.identity.log.messageid.LogMessageProviderBase) IOException(java.io.IOException)

Example 3 with LogMessageProviderBase

use of com.sun.identity.log.messageid.LogMessageProviderBase in project OpenAM by OpenRock.

the class LogManager method logIt.

private void logIt(Logger logger, String[] msg, String msgName) {
    try {
        LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Logging");
        SSOToken ssot = LogManagerUtil.getLoggingSSOToken();
        com.sun.identity.log.LogRecord lr = provider.createLogRecord(msgName, msg, ssot);
        logger.log(lr, ssot);
        logger.flush();
    } catch (IOException ioex) {
        Debug.error("LogManager.logIt:could not log to " + logger.getName() + ": " + ioex.getMessage());
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogMessageProviderBase(com.sun.identity.log.messageid.LogMessageProviderBase) IOException(java.io.IOException)

Example 4 with LogMessageProviderBase

use of com.sun.identity.log.messageid.LogMessageProviderBase in project OpenAM by OpenRock.

the class Logger method logStartRecord.

/**
     *  Log a LogRecord indicating the start of logging to this file
     */
private static void logStartRecord(Logger logger) {
    /*
         *  SSOToken not required to instantiate a log file, so
         *  need one to say who's doing the logging of the record,
         *  and whose it "about".
         */
    try {
        LogMessageProviderBase provider = (LogMessageProviderBase) MessageProviderFactory.getProvider("Logging");
        SSOToken ssot = LogManagerUtil.getLoggingSSOToken();
        String location = lm.getProperty(LogConstants.LOG_LOCATION);
        String[] s = { location };
        com.sun.identity.log.LogRecord lr = provider.createLogRecord(LogConstants.START_LOG_NEW_LOGGER_NAME, s, ssot);
        logger.log(lr, ssot);
    } catch (IOException ioex) {
        Debug.error("Logger.logStartRecord:could not log to " + logger.getName() + ":" + ioex.getMessage());
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogMessageProviderBase(com.sun.identity.log.messageid.LogMessageProviderBase) IOException(java.io.IOException)

Aggregations

SSOToken (com.iplanet.sso.SSOToken)4 LogMessageProviderBase (com.sun.identity.log.messageid.LogMessageProviderBase)4 IOException (java.io.IOException)4 Logger (com.sun.identity.log.Logger)1 Enumeration (java.util.Enumeration)1