use of org.apache.log4j.spi.LoggingEvent in project gerrit by GerritCodeReview.
the class SshLog method onAuthFail.
void onAuthFail(final SshSession sd) {
final LoggingEvent event = new //
LoggingEvent(// fqnOfCategoryClass
Logger.class.getName(), // logger
log, // when
TimeUtil.nowMs(), // level
Level.INFO, // message text
"AUTH FAILURE FROM " + sd.getRemoteAddressAsString(), // thread name
"SSHD", // exception information
null, // current NDC string
null, // caller location
null, // MDC properties
null);
event.setProperty(P_SESSION, id(sd.getSessionId()));
event.setProperty(P_USER_NAME, sd.getUsername());
final String error = sd.getAuthenticationError();
if (error != null) {
event.setProperty(P_STATUS, error);
}
if (async != null) {
async.append(event);
}
audit(null, "FAIL", "AUTH");
}
use of org.apache.log4j.spi.LoggingEvent in project gerrit by GerritCodeReview.
the class SshLog method log.
private LoggingEvent log(final String msg) {
final SshSession sd = session.get();
final CurrentUser user = sd.getUser();
final LoggingEvent event = new //
LoggingEvent(// fqnOfCategoryClass
Logger.class.getName(), // logger
log, // when
TimeUtil.nowMs(), // level
Level.INFO, // message text
msg, // thread name
"SSHD", // exception information
null, // current NDC string
null, // caller location
null, // MDC properties
null);
event.setProperty(P_SESSION, id(sd.getSessionId()));
String userName = "-";
String accountId = "-";
if (user != null && user.isIdentifiedUser()) {
IdentifiedUser u = user.asIdentifiedUser();
userName = u.getAccount().getUserName();
accountId = "a/" + u.getAccountId().toString();
} else if (user instanceof PeerDaemonUser) {
userName = PeerDaemonUser.USER_NAME;
}
event.setProperty(P_USER_NAME, userName);
event.setProperty(P_ACCOUNT_ID, accountId);
return event;
}
use of org.apache.log4j.spi.LoggingEvent in project gerrit by GerritCodeReview.
the class SshLog method onLogin.
void onLogin() {
LoggingEvent entry = log("LOGIN FROM " + session.get().getRemoteAddressAsString());
if (async != null) {
async.append(entry);
}
audit(context.get(), "0", "LOGIN");
}
use of org.apache.log4j.spi.LoggingEvent in project JMRI by JMRI.
the class JLogoutputFrame method log.
/**
* Outputs a message only to the appender which belongs to this frame
*
* @param aLevel logging level
* @param aMsg logging message
*/
public void log(Level aLevel, String aMsg) {
if (myAppender == null) {
return;
}
// if myAppender == null
LoggingEvent event = new LoggingEvent(this.getClass().getName(), myLog, aLevel, aMsg, null);
myAppender.append(event);
}
use of org.apache.log4j.spi.LoggingEvent in project JMRI by JMRI.
the class JUnitAppender method verifyNoBacklog.
/**
* Verify that no messages were emitted, logging any that were. Does not
* stop the logging. Clears the accumulated list.
*
* @return true if no messages logged
*/
public static boolean verifyNoBacklog() {
if (list.isEmpty()) {
return true;
}
while (!list.isEmpty()) {
// should probably add a skip of lower levels?
LoggingEvent evt = list.remove(0);
instance().superappend(evt);
}
return false;
}
Aggregations