+ if (dispatching.get())
+ return;
+
+ if (level != null && !level.trim().equals("")) {
+ if (log4jLevel == null || !log4jLevel.toString().equals(level))
+ try {
+ log4jLevel = Level.toLevel(level);
+ } catch (Exception e) {
+ System.err
+ .println("Log4j level could not be set for level '"
+ + level + "', resetting it to null.");
+ e.printStackTrace();
+ level = null;
+ }
+
+ if (log4jLevel != null
+ && !event.getLevel().isGreaterOrEqual(log4jLevel)) {
+ return;
+ }
+ }
+
+ Thread currentThread = Thread.currentThread();
+ if (currentThread.getThreadGroup() instanceof ProcessThreadGroup) {
+ if (onlyExecutionThread
+ && !(currentThread instanceof ExecutionThread))
+ return;
+
+ final String type;
+ if (event.getLevel().equals(Level.ERROR)
+ || event.getLevel().equals(Level.FATAL))
+ type = ExecutionStep.ERROR;
+ else if (event.getLevel().equals(Level.WARN))
+ type = ExecutionStep.WARNING;
+ else if (event.getLevel().equals(Level.INFO))
+ type = ExecutionStep.INFO;
+ else if (event.getLevel().equals(Level.DEBUG))
+ type = ExecutionStep.DEBUG;
+ else if (event.getLevel().equals(Level.TRACE))
+ type = ExecutionStep.TRACE;
+ else
+ type = ExecutionStep.INFO;
+
+ ExecutionStep step = new ExecutionStep(new Date(
+ event.getTimeStamp()), type, layout.format(event));
+
+ try {
+ dispatching.set(true);
+ ((ProcessThreadGroup) currentThread.getThreadGroup())
+ .dispatchAddStep(step);
+ } finally {
+ dispatching.set(false);
+ }
+ }