if (categoryName != null) record.setLoggerName(categoryName); record.setMdc(mdcCopy == null ? Collections.<Object, Object>emptyMap() : mdcCopy); record.setNdc(ndc == null ? "" : ndc); record.setMillis(timeStamp); record.setThreadName(threadName == null ? "<unknown>" : threadName);
logRecord.setNdc(ndc);
/** * Get a log record for a log4j event. If the event wraps a log record, that record is returned; otherwise * a new record is built up from the event. * * @param event the event * @return the log record */ public static ExtLogRecord getLogRecordFor(LoggingEvent event) { final ExtLogRecord rec = (ExtLogRecord)event.getProperties().get("org.jboss.logmanager.record"); if (rec != null) { return rec; } final ExtLogRecord newRecord = new ExtLogRecord(LevelMapping.getLevelFor(event.getLevel()), (String) event.getMessage(), event.getFQNOfLoggerClass()); newRecord.setLoggerName(event.getLoggerName()); newRecord.setMillis(event.getTimeStamp()); newRecord.setThreadName(event.getThreadName()); newRecord.setThrown(event.getThrowableInformation().getThrowable()); newRecord.setNdc(event.getNDC()); if (event.locationInformationExists()) { final LocationInfo locationInfo = event.getLocationInformation(); newRecord.setSourceClassName(locationInfo.getClassName()); newRecord.setSourceFileName(locationInfo.getFileName()); newRecord.setSourceLineNumber(Integer.parseInt(locationInfo.getLineNumber())); newRecord.setSourceMethodName(locationInfo.getMethodName()); } return newRecord; } }