use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.
the class OpenSSOLogger method log.
public static void log(LogLevel type, Level level, String msgid, String[] msgdata, Subject logFor) {
Logger logger = (type.equals(LogLevel.ERROR)) ? LoggerFactory.getLogger(LOG_NAME + ".error") : LoggerFactory.getLogger(LOG_NAME + ".access");
if (logger.isLoggable(level)) {
try {
LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
LogRecord logRec = msgProvider.createLogRecord(msgid, msgdata, SubjectUtils.getSSOToken(logFor));
if (logRec != null) {
logger.log(getERecord(logRec));
}
} catch (IOException ex) {
Logger.getLogger(OpenSSOLogger.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.
the class TokenLogUtils method access.
/**
* Logs message to core token access logs.
*
* @param level the log level , these are based on those
* defined in java.util.logging.Level, the values for
* level can be any one of the following : <br>
* <ul>
* <li>SEVERE (highest value) <br>
* <li>WARNING <br>
* <li>INFO <br>
* <li>CONFIG <br>
* <li>FINE <br>
* <li>FINER <br>
* <li>FINEST (lowest value) <br>
* </ul>
* @param msgid the message or a message identifier.
* @param data string array of dynamic data to be replaced in the message.
* @param session the User's session object
* @param nameId value for NameID logging field
*/
public static void access(Level level, String msgid, String[] data, SSOToken session, String nameId) {
if (logActive) {
try {
if (isAccessLoggable(level)) {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
LogRecord logRec = msgProvider.createLogRecord(msgid, data, session);
logRec.addLogInfo(TokenLogUtils.TOKEN_NAME_ID, nameId);
if (logRec != null) {
accessLogger.log(logRec, adminToken);
}
}
} catch (IOException le) {
CoreTokenUtils.debug.error("TokenLogUtils.error:Couldn't write error log:", le);
}
}
}
use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.
the class TokenLogUtils method error.
/**
* Logs error messages to core token error log.
*
* @param level the log level , these are based on those
* defined in java.util.logging.Level, the values for
* level can be any one of the following : <br>
* <ul>
* <li>SEVERE (highest value) <br>
* <li>WARNING <br>
* <li>INFO <br>
* <li>CONFIG <br>
* <li>FINE <br>
* <li>FINER <br>
* <li>FINEST (lowest value) <br>
* </ul>
* @param msgid the message or a message identifier.
* @param data string array of dynamic data to be replaced in the message.
* @param session the User's Session object.
* @param nameId value for NameID logging field
*/
public static void error(Level level, String msgid, String[] data, SSOToken session, String nameId) {
if (logActive) {
try {
if (isErrorLoggable(level)) {
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
LogRecord logRec = msgProvider.createLogRecord(msgid, data, session);
logRec.addLogInfo(TokenLogUtils.TOKEN_NAME_ID, nameId);
if (logRec != null) {
errorLogger.log(logRec, adminToken);
}
}
} catch (IOException le) {
CoreTokenUtils.debug.error("TokenLogUtils.error:Couldn't write error log:", le);
}
}
}
use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.
the class LogWriter method log.
/**
* Writes to log.
*
* @param mgr Command Manager Object.
* @param type Type of log message.
* @param level Logging level of the message.
* @param msgid ID for message.
* @param msgdata array of log message "data".
* @param ssoToken Single Sign On Token of the user who committed the
* operation.
* @throws CLIException if log cannot be written.
*/
public static void log(CommandManager mgr, int type, Level level, String msgid, String[] msgdata, SSOToken ssoToken) throws CLIException {
if (!mgr.isLogOff()) {
Logger logger;
String logName = mgr.getLogName();
switch(type) {
case LOG_ERROR:
logger = (com.sun.identity.log.Logger) Logger.getLogger(logName + ".error");
break;
default:
logger = (com.sun.identity.log.Logger) Logger.getLogger(logName + ".access");
}
try {
LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
SSOToken adminSSOToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
if (ssoToken == null) {
ssoToken = adminSSOToken;
}
if (logger.isLoggable(level)) {
LogRecord logRec = msgProvider.createLogRecord(msgid, msgdata, ssoToken);
if (logRec != null) {
logger.log(logRec, adminSSOToken);
}
}
logToAuditService(type, msgid, msgdata, ssoToken, msgProvider, adminSSOToken);
} catch (Exception e) {
throw new CLIException(e, ExitCodes.CANNOT_WRITE_LOG);
}
}
}
use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.
the class AMModelBase method logEvent.
/**
* Writes log event.
*
* @param id Log Message ID.
* @param data Log Data.
*/
public void logEvent(String id, String[] data) {
try {
LogMessageProvider provider = MessageProviderFactory.getProvider(LOG_PROVIDER);
LogRecord rec = provider.createLogRecord(id, data, ssoToken);
if (rec != null) {
AMAdminLog.getInstance().doLog(rec);
} else {
debug.error("AMModelBase.logEvent: missing log entry, " + id);
}
} catch (IOException e) {
debug.error("AMModelBase.logEvent", e);
}
}
Aggregations