private LoggingEvent convertToEvent(Map fieldMap, String[] exception) {
    if (fieldMap == null) {
      return null;
    }

    //a logger must exist at a minimum for the event to be processed
    if (!fieldMap.containsKey(LOGGER)) {
      fieldMap.put(LOGGER, "Unknown");
    }
    if (exception == null) {
      exception = emptyException;
    }

    Logger logger = null;
    long timeStamp = 0L;
    String level = null;
    String threadName = null;
    Object message = null;
    String ndc = null;
    String className = null;
    String methodName = null;
    String eventFileName = null;
    String lineNumber = null;
    Hashtable properties = new Hashtable();

    logger = Logger.getLogger((String) fieldMap.remove(LOGGER));

    if ((dateFormat != null) && fieldMap.containsKey(TIMESTAMP)) {
      try {
        timeStamp = dateFormat.parse((String) fieldMap.remove(TIMESTAMP))
            .getTime();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    //use current time if timestamp not parseable
    if (timeStamp == 0L) {
      timeStamp = System.currentTimeMillis();
    }

    message = fieldMap.remove(MESSAGE);
    if (message == null) {
      message = "";
    }

    level = (String) fieldMap.remove(LEVEL);
    Level levelImpl;
    if (level == null) {
        levelImpl = Level.DEBUG;
    } else {
        //first try to resolve against custom level definition map, then fall back to regular levels
        levelImpl = (Level) customLevelDefinitionMap.get(level);
        if (levelImpl == null) {
            levelImpl = Level.toLevel(level.trim());
            if (!level.equals(levelImpl.toString())) {
                //check custom level map
                if (levelImpl == null) {
                    levelImpl = Level.DEBUG;
                    getLogger().debug("found unexpected level: " + level + ", logger: " + logger.getName() + ", msg: " + message);
                    //make sure the text that couldn't match a level is added to the message
                    message = level + " " + message;
                }
            }
        }
    }

    threadName = (String) fieldMap.remove(THREAD);

    ndc = (String) fieldMap.remove(NDC);

    className = (String) fieldMap.remove(CLASS);

    methodName = (String) fieldMap.remove(METHOD);

    eventFileName = (String) fieldMap.remove(FILE);

    lineNumber = (String) fieldMap.remove(LINE);

    properties.put(Constants.HOSTNAME_KEY, host);
    properties.put(Constants.APPLICATION_KEY, path);
    properties.put(Constants.RECEIVER_NAME_KEY, getName());

    //all remaining entries in fieldmap are properties
    properties.putAll(fieldMap);

    LocationInfo info = null;

    if ((eventFileName != null) || (className != null) || (methodName != null)
        || (lineNumber != null)) {
      info = new LocationInfo(eventFileName, className, methodName, lineNumber);
    } else {
      info = LocationInfo.NA_LOCATION_INFO;
    }

    LoggingEvent event = new LoggingEvent(null,
            logger, timeStamp, levelImpl, message,
            threadName,
            new ThrowableInformation(exception),
            ndc,
            info,
            properties);

    return event;
  }
private LoggingEvent convertToEvent ( Map fieldMap , String [ ] exception ) { if ( fieldMap == null ) { return null ; } if ( ! fieldMap . containsKey ( LOGGER ) ) { fieldMap . put ( LOGGER , "Unknown" ) ; } if ( exception == null ) { exception = emptyException ; } Logger logger = null ; long timeStamp = 0L ; String level = null ; String threadName = null ; Object message = null ; String ndc = null ; String className = null ; String methodName = null ; String eventFileName = null ; String lineNumber = null ; Hashtable properties = new Hashtable ( ) ; logger = Logger . getLogger ( ( String ) fieldMap . remove ( LOGGER ) ) ; if ( ( dateFormat != null ) && fieldMap . containsKey ( TIMESTAMP ) ) { try { timeStamp = dateFormat . parse ( ( String ) fieldMap . remove ( TIMESTAMP ) ) . getTime ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } if ( timeStamp == 0L ) { timeStamp = System . currentTimeMillis ( ) ; } message = fieldMap . remove ( MESSAGE ) ; if ( message == null ) { message = "" ; } level = ( String ) fieldMap . remove ( LEVEL ) ; Level levelImpl ; if ( level == null ) { levelImpl = Level . DEBUG ; } else { levelImpl = ( Level ) customLevelDefinitionMap . get ( level ) ; if ( levelImpl == null ) { levelImpl = Level . toLevel ( level . trim ( ) ) ; if ( ! level . equals ( levelImpl . toString ( ) ) ) { if ( levelImpl == null ) { levelImpl = Level . DEBUG ; getLogger ( ) . debug ( "found unexpected level: " + level + ", logger: " + logger . getName ( ) + ", msg: " + message ) ; message = level + " " + message ; } } } } threadName = ( String ) fieldMap . remove ( THREAD ) ; ndc = ( String ) fieldMap . remove ( NDC ) ; className = ( String ) fieldMap . remove ( CLASS ) ; methodName = ( String ) fieldMap . remove ( METHOD ) ; eventFileName = ( String ) fieldMap . remove ( FILE ) ; lineNumber = ( String ) fieldMap . remove ( LINE ) ; properties . put ( Constants . HOSTNAME_KEY , host ) ; properties . put ( Constants . APPLICATION_KEY , path ) ; properties . put ( Constants . RECEIVER_NAME_KEY , getName ( ) ) ; properties . putAll ( fieldMap ) ; LocationInfo info = null ; if ( ( eventFileName != null ) || ( className != null ) || ( methodName != null ) || ( lineNumber != null ) ) { info = new LocationInfo ( eventFileName , className , methodName , lineNumber ) ; } else { info = LocationInfo . NA_LOCATION_INFO ; } LoggingEvent event = new LoggingEvent ( null , logger , timeStamp , levelImpl , message , threadName , new ThrowableInformation ( exception ) , ndc , info , properties ) ; return event ; }
Convert a keyword-to-values map to a LoggingEvent

@param fieldMap
@param exception

@return logging event