public String convert(LoggingEvent event) {
   if (key == null) {
     StringBuffer buf = new StringBuffer("{");
     Map properties = event.getProperties();
     if (properties.size() > 0) {
       Object[] keys = properties.keySet().toArray();
       Arrays.sort(keys);
       for (int i = 0; i < keys.length; i++) {
         buf.append('{');
         buf.append(keys[i]);
         buf.append(',');
         buf.append(properties.get(keys[i]));
         buf.append('}');
       }
     }
     buf.append('}');
     return buf.toString();
   } else {
     Object val = event.getMDC(key);
     if (val == null) {
       return null;
     } else {
       return val.toString();
     }
   }
 }
Beispiel #2
0
 private void opt(String key, StringBuffer buf, LoggingEvent event) {
   Object val = event.getMDC(key);
   if (val != null) {
     buf.append(' ');
     buf.append(val);
   }
 }
 /*     */ public String convert(LoggingEvent event) /*     */ {
   /* 463 */ Object val = event.getMDC(this.key);
   /* 464 */ if (val == null) {
     /* 465 */ return null;
     /*     */ }
   /* 467 */ return val.toString();
   /*     */ }
Beispiel #4
0
 /**
  * Convert logging event to map
  *
  * @param e
  * @return
  */
 public static Map<String, Object> toMap(LoggingEvent e) {
   final Map<String, Object> m =
       Objects.newHashMap(
           "name", e.getLoggerName(),
           "date", new Date(e.getTimeStamp()),
           "level", e.getLevel().toString(),
           "thread", e.getThreadName(),
           "message", "" + e.getMessage(),
           "fileName", e.getLocationInformation().getFileName(),
           "methodName", e.getLocationInformation().getMethodName(),
           "lineNumber", e.getLocationInformation().getLineNumber(),
           "requestId", e.getMDC("requestId"),
           "sessionId", e.getMDC("sessionId"),
           "freeMemory", Runtime.getRuntime().freeMemory(),
           "throwable", null);
   if (e.getThrowableInformation() != null && e.getThrowableInformation().getThrowable() != null) {
     Throwable t = e.getThrowableInformation().getThrowable();
     m.put(
         "throwable",
         Objects.newHashMap(
             "message", t.getMessage(),
             "class", t.getClass().getName(),
             "stackTrace", getStackTrace(t)));
   }
   return m;
 }
Beispiel #5
0
 private LogMessageEntity convertToLogMessageEntity(LoggingEvent loggingEvent)
     throws UnknownHostException {
   return new LogMessageEntity(
       loggingEvent.getTimeStamp(),
       loggingEvent.getRenderedMessage(),
       new PatternLayout("%C{1}").format(loggingEvent),
       (String) loggingEvent.getMDC(MDCHelper.MDC_TRANSACTION_ID),
       String.format("%s / %s", nodeId, InetAddress.getLocalHost().getHostName()));
 }
Beispiel #6
0
 private void req(String key, StringBuffer buf, LoggingEvent event) {
   Object val = event.getMDC(key);
   buf.append(' ');
   if (val != null) {
     String s = val.toString();
     if (0 <= s.indexOf(' ')) {
       buf.append(QuotedString.BOURNE.quote(s));
     } else {
       buf.append(val);
     }
   } else {
     buf.append('-');
   }
 }
  @Override
  protected synchronized void append(LoggingEvent ev) {
    Object application = ev.getMDC("application");
    if (application == null || application.toString().isEmpty()) return;

    DedupedLogEvent dev = new DedupedLogEvent(ev);

    // if event is present, increase the count
    if (events.containsKey(dev.toString())) {
      DedupedLogEvent oldDev = events.remove(dev.toString());
      dev.setCount(oldDev.getCount() + 1);
    }
    events.put(dev.toString(), dev);
  }