private ChainsawLoggingEvent convertToEvent()

in src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java [901:1008]


    private ChainsawLoggingEvent 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;
        }

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

        logger = (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/dateformat not specified
        if (timeStamp == 0L) {
            timeStamp = System.currentTimeMillis();
        }

        message = (String)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 = 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;
//                        logger.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());
        if (group != null) {
            properties.put(Constants.GROUP_KEY, group);
        }

        //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, 
                    Integer.parseInt(lineNumber));
        }

        build.clear();
        build.setLogger(logger)
                .setTimestamp(Instant.ofEpochMilli(timeStamp))
                .setLevelFromString(level)
                .setMessage(message)
                .setThreadName(threadName)
                .setLocationInfo(info)
                .setNDC(ndc)
                .setMDC(properties);

        return build.create();
    }