protected void appendMavenCoordinates(LoggingEvent loggingEvent) { LocationInfo information = loggingEvent.getLocationInformation(); if (information != null) { String coordinates = MavenCoordHelper.getMavenCoordinates(information.getClassName()); if (coordinates != null) { loggingEvent.setProperty("maven.coordinates", coordinates); } } }
event.setProperty("application", application);
event.setProperty("application", application);
event.setProperty("application", application);
event.setProperty("application", application);
/** * Retrieve the event properties from the logging_event_property table. * * @param connection * @param id * @param event * @throws SQLException */ void getProperties(Connection connection, long id, LoggingEvent event) throws SQLException { PreparedStatement statement = connection.prepareStatement(sqlProperties); try { statement.setLong(1, id); ResultSet rs = statement.executeQuery(); while (rs.next()) { String key = rs.getString(1); String value = rs.getString(2); event.setProperty(key, value); } } finally { statement.close(); } }
/** * Retrieve the event properties from the logging_event_property table. * * @param connection * @param id * @param event * @throws SQLException */ void getProperties(Connection connection, long id, LoggingEvent event) throws SQLException { PreparedStatement statement = connection.prepareStatement(sqlProperties); try { statement.setLong(1, id); ResultSet rs = statement.executeQuery(); while (rs.next()) { String key = rs.getString(1); String value = rs.getString(2); event.setProperty(key, value); } } finally { statement.close(); } }
private void processEvents(Collection c) { if (c == null) { return; } for (Iterator iter = c.iterator(); iter.hasNext();) { LoggingEvent evt = (LoggingEvent) iter.next(); if (passesExpression(evt)) { if (evt.getProperty(Constants.HOSTNAME_KEY) != null) { evt.setProperty(Constants.HOSTNAME_KEY, host); } if (evt.getProperty(Constants.APPLICATION_KEY) != null) { evt.setProperty(Constants.APPLICATION_KEY, path); } doPost(evt); } } }
private void processEvents(Collection c) { if (c == null) { return; } for (Iterator iter = c.iterator(); iter.hasNext();) { LoggingEvent evt = (LoggingEvent) iter.next(); if (passesExpression(evt)) { if (evt.getProperty(Constants.HOSTNAME_KEY) != null) { evt.setProperty(Constants.HOSTNAME_KEY, host); } if (evt.getProperty(Constants.APPLICATION_KEY) != null) { evt.setProperty(Constants.APPLICATION_KEY, path); } doPost(evt); } } }
public class CurrentThreadIdAppender extends AppenderSkeleton implements AppenderAttachable { private final AppenderAttachableImpl appenders = new AppenderAttachableImpl(); ... @Override protected void append(LoggingEvent event) { synchronized (appenders) { event.setProperty("threadId", String.valueOf(Thread.currentThread().getId())); appenders.appendLoopOnAppenders(event); } } ... }
void onExecute(int exitValue) { final Context ctx = context.get(); ctx.finished = System.currentTimeMillis(); final String commandLine = ctx.getCommandLine(); String cmd = QuotedString.BOURNE.quote(commandLine); if (cmd == commandLine) { cmd = "'" + commandLine + "'"; } final LoggingEvent event = log(cmd); event.setProperty(P_WAIT, (ctx.started - ctx.created) + "ms"); event.setProperty(P_EXEC, (ctx.finished - ctx.started) + "ms"); final String status; switch (exitValue) { case BaseCommand.STATUS_CANCEL: status = "killed"; break; case BaseCommand.STATUS_NOT_FOUND: status = "not-found"; break; case BaseCommand.STATUS_NOT_ADMIN: status = "not-admin"; break; default: status = String.valueOf(exitValue); break; } event.setProperty(P_STATUS, status); async.append(event); }
private LoggingEvent log(final String msg) { final SshSession sd = session.get(); final CurrentUser user = sd.getCurrentUser(); final LoggingEvent event = new LoggingEvent( // Logger.class.getName(), // fqnOfCategoryClass null, // logger (optional) System.currentTimeMillis(), // when Level.INFO, // level msg, // message text "SSHD", // thread name null, // exception information null, // current NDC string null, // caller location null // MDC properties ); event.setProperty(P_SESSION, id(sd.getSessionId())); String userName = "-", accountId = "-"; if (user instanceof IdentifiedUser) { IdentifiedUser u = (IdentifiedUser) user; userName = u.getUserName(); } event.setProperty(P_USER_NAME, userName); event.setProperty(P_ACCOUNT_ID, accountId); return event; }
private LoggingEvent log(final String msg) { final SshSession sd = session.get(); final CurrentUser user = sd.getCurrentUser(); final LoggingEvent event = new LoggingEvent( // Logger.class.getName(), // fqnOfCategoryClass null, // logger (optional) System.currentTimeMillis(), // when Level.INFO, // level msg, // message text "SSHD", // thread name null, // exception information null, // current NDC string null, // caller location null // MDC properties ); event.setProperty(P_SESSION, id(sd.getSessionId())); String userName = "-", accountId = "-"; if (user instanceof IdentifiedUser) { IdentifiedUser u = (IdentifiedUser) user; userName = u.getUserName(); } event.setProperty(P_USER_NAME, userName); event.setProperty(P_ACCOUNT_ID, accountId); return event; }
protected void appendMavenCoordinates(LoggingEvent loggingEvent) { LocationInfo information = loggingEvent.getLocationInformation(); if (information != null) { String coordinates = MavenCoordHelper.getMavenCoordinates(information.getClassName()); if (coordinates != null) { loggingEvent.setProperty("maven.coordinates", coordinates); } } }
void onAuthFail(final SshSession sd) { final LoggingEvent event = new LoggingEvent( // Logger.class.getName(), // fqnOfCategoryClass null, // logger (optional) System.currentTimeMillis(), // when Level.INFO, // level "AUTH FAILURE FROM " + sd.getRemoteAddressAsString(), // message text "SSHD", // thread name null, // exception information null, // current NDC string null, // caller location null // MDC properties ); 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); } async.append(event); }
void onAuthFail(final SshSession sd) { final LoggingEvent event = new LoggingEvent( // Logger.class.getName(), // fqnOfCategoryClass null, // logger (optional) System.currentTimeMillis(), // when Level.INFO, // level "AUTH FAILURE FROM " + sd.getRemoteAddressAsString(), // message text "SSHD", // thread name null, // exception information null, // current NDC string null, // caller location null // MDC properties ); 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); } async.append(event); }
protected void appendMavenCoordinates(LoggingEvent loggingEvent) { LocationInfo information = loggingEvent.getLocationInformation(); if (information != null) { String coordinates = MavenCoordHelper.getMavenCoordinates(information.getClassName()); if (coordinates != null) { loggingEvent.setProperty("maven.coordinates", coordinates); } } }
protected void appendMavenCoordinates(LoggingEvent loggingEvent) { LocationInfo information = loggingEvent.getLocationInformation(); if (information != null) { String coordinates = MavenCoordHelper.getMavenCoordinates(information.getClassName()); if (coordinates != null) { loggingEvent.setProperty("maven.coordinates", coordinates); } } }
public void onMessage(Message message) { try { if(message instanceof ObjectMessage) { // get the logging event and post it to the repository ObjectMessage objectMessage = (ObjectMessage) message; LoggingEvent event = (LoggingEvent) objectMessage.getObject(); // store the known remote info in an event property event.setProperty("log4j.remoteSourceInfo", remoteInfo); event.setProperty("log4j.jmsProviderUrl", providerUrl); doPost(event); } else { getLogger().warn("Received message is of type "+message.getJMSType() +", was expecting ObjectMessage."); } } catch(Exception e) { getLogger().error("Exception thrown while processing incoming message.", e); } }
public void onMessage(Message message) { try { if(message instanceof ObjectMessage) { // get the logging event and post it to the repository ObjectMessage objectMessage = (ObjectMessage) message; LoggingEvent event = (LoggingEvent) objectMessage.getObject(); // store the known remote info in an event property event.setProperty("log4j.remoteSourceInfo", remoteInfo); event.setProperty("log4j.jmsProviderUrl", providerUrl); doPost(event); } else { getLogger().warn("Received message is of type "+message.getJMSType() +", was expecting ObjectMessage."); } } catch(Exception e) { getLogger().error("Exception thrown while processing incoming message.", e); } }