/** * Check for the existence of location information without creating it * (a byproduct of calling getLocationInformation). * * @return true if location information has been extracted. * * @since 1.2.15 */ public final boolean locationInformationExists() { return m_delegate.locationInformationExists(); }
/** * Check for the existence of location information without creating it * (a byproduct of calling getLocationInformation). * * @return true if location information has been extracted. * * @since 1.2.15 */ public final boolean locationInformationExists() { return m_delegate.locationInformationExists(); }
protected void append(LoggingEvent event) { String message = null; if(event.locationInformationExists()){ StringBuilder formatedMessage = new StringBuilder(); formatedMessage.append(event.getLocationInformation().getClassName());
if (event.locationInformationExists()) { StringBuilder formatedMessage = new StringBuilder(); formatedMessage.append(event.getLocationInformation().getClassName());
if (event.locationInformationExists() || locationInfo) { li = event.getLocationInformation(); } else {
if (event.locationInformationExists() || locationInfo) { li = event.getLocationInformation(); } else {
@Override public Map<String, String> getCustomParameters() { Map<String, String> metaData = new HashMap<String, String>(); metaData.put("SourceType", "Log4j"); addLogEventProperty("LoggerName", loggingEvent.getLoggerName(), metaData); addLogEventProperty("LoggingLevel", loggingEvent.getLevel() != null ? loggingEvent.getLevel().toString() : null, metaData); addLogEventProperty("ThreadName", loggingEvent.getThreadName(), metaData); addLogEventProperty("TimeStamp", getFormattedDate(loggingEvent.getTimeStamp()), metaData); if (isException()) { addLogEventProperty("Logger Message", getMessage(), metaData); } if (loggingEvent.locationInformationExists()) { LocationInfo locationInfo = loggingEvent.getLocationInformation(); addLogEventProperty("ClassName", locationInfo.getClassName(), metaData); addLogEventProperty("FileName", locationInfo.getFileName(), metaData); addLogEventProperty("MethodName", locationInfo.getMethodName(), metaData); addLogEventProperty("LineNumber", String.valueOf(locationInfo.getLineNumber()), metaData); } for (Object o : loggingEvent.getProperties().entrySet()) { Map.Entry<String, Object> entry = (Map.Entry<String, Object>) o; addLogEventProperty(entry.getKey(), entry.getValue().toString(), metaData); } // TODO: Username, domain and identity should be included as in .NET version. // TODO: Should check, seems that it is not included in Log4j2. return metaData; }
/** * 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; } }