use of com.sun.identity.log.LogRecord 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);
}
}
use of com.sun.identity.log.LogRecord in project OpenAM by OpenRock.
the class OAuth2AuditLogger method logAccessMessage.
/**
* Logs an access message.
*
* @param msgIdName The message id name.
* @param data The data to log.
* @param token The SSO Token to authenticate the log operation.
*/
public void logAccessMessage(String msgIdName, String[] data, SSOToken token) {
try {
getLogMessageProvider();
} catch (IOException e) {
logger.error(e.getMessage(), e);
logger.error("disabling logging");
logStatus = false;
}
if ((accessLogger != null) && (msgProvider != null)) {
final LogRecord lr = msgProvider.createLogRecord(msgIdName, data, token);
if (lr != null) {
final SSOToken ssoToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
accessLogger.log(lr, ssoToken);
}
}
}
use of com.sun.identity.log.LogRecord in project OpenAM by OpenRock.
the class OAuth2AuditLogger method logErrorMessage.
/**
* Logs an error message.
*
* @param msgIdName The message id name.
* @param data The data to log.
* @param token The SSO Token to authenticate the log operation.
*/
public void logErrorMessage(String msgIdName, String[] data, SSOToken token) {
try {
getLogMessageProvider();
} catch (IOException e) {
logger.error(e.getMessage(), e);
logger.error("disabling logging");
logStatus = false;
}
if (errorLogger != null && msgProvider != null) {
final LogRecord lr = msgProvider.createLogRecord(msgIdName, data, token);
if (lr != null) {
final SSOToken ssoToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
errorLogger.log(lr, ssoToken);
}
}
}
use of com.sun.identity.log.LogRecord in project OpenAM by OpenRock.
the class SessionLogging method logIt.
private void logIt(SessionInfo sessionInfo, String eventId) {
try {
String clientID = sessionInfo.getClientID();
String uidData;
if (StringUtils.isEmpty(clientID)) {
uidData = "N/A";
} else {
StringTokenizer st = new StringTokenizer(clientID, ",");
uidData = (st.hasMoreTokens()) ? st.nextToken() : clientID;
}
String[] data = { uidData };
LogRecord lr = getLogMessageProvider().createLogRecord(eventId, data, null);
lr.addLogInfo(LogConstants.LOGIN_ID_SID, sessionInfo.getSessionID());
lr.addLogInfo(LogConstants.CONTEXT_ID, sessionInfo.getProperties().get(Constants.AM_CTX_ID));
lr.addLogInfo(LogConstants.LOGIN_ID, clientID);
lr.addLogInfo(LogConstants.LOG_LEVEL, lr.getLevel().toString());
lr.addLogInfo(LogConstants.DOMAIN, sessionInfo.getClientDomain());
lr.addLogInfo(LogConstants.IP_ADDR, sessionInfo.getProperties().get(HOST_PROP));
lr.addLogInfo(LogConstants.HOST_NAME, sessionInfo.getProperties().get(HOSTNAME_PROP));
getLogger().log(lr, AccessController.doPrivileged(adminTokenAction));
} catch (Exception ex) {
sessionDebug.error("SessionService.logIt(): Cannot write to the session log file: ", ex);
}
}
use of com.sun.identity.log.LogRecord in project OpenAM by OpenRock.
the class SessionLogging method logSystemMessage.
public void logSystemMessage(String msgID, Level level) {
if (!serviceConfig.isLoggingEnabled()) {
return;
}
try {
String[] data = { msgID };
LogRecord lr = getLogMessageProvider().createLogRecord(msgID, data, null);
SSOToken serviceToken = AccessController.doPrivileged(adminTokenAction);
lr.addLogInfo(LogConstants.LOGIN_ID_SID, serviceToken.getTokenID().toString());
lr.addLogInfo(LogConstants.LOGIN_ID, serviceToken.getPrincipal().getName());
getErrorLogger().log(lr, serviceToken);
} catch (Exception ex) {
sessionDebug.error("SessionService.logSystemMessage(): Cannot write to the session error log file: ", ex);
}
}
Aggregations