uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccLogger.java [225:599]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        this.logger = Logger.getLogger(claz);
        MDC.put("COMPONENT", component);

        ErrorHandler errHandler = new DuccLogErrorHandler(this);
        @SuppressWarnings("rawtypes")
        Enumeration appenders = logger.getAllAppenders();
        while (appenders.hasMoreElements() ) {
            Appender app = (Appender) appenders.nextElement();
            app.setErrorHandler(errHandler);
        }
    }

    public DuccLogger(@SuppressWarnings("rawtypes") Class claz, String component)
    {
        this(claz.getName(), component);
    }
        
    public DuccLogger(@SuppressWarnings("rawtypes") Class claz)
    {
        this(claz, null);
    }
    
    public DuccLogger(String claz)
    {
        this(claz, null);
    }

    public boolean isDefaultLogger()
    {
        return this.component.equals(DEFAULT_COMPONENT);
    }

    public void setAdditionalAppenders()
    {
    	if ( debug ) System.out.println("============ Looking for appenders -----------");
        if ( isDefaultLogger() ) {
            if ( debug ) System.out.println(" ---> Skipping appender search for default component");
            return;
        }

        Category l = logger;
        // List<Appender> appenders= new ArrayList<Appender>();
        while ( l != null ) {
        	@SuppressWarnings("rawtypes")
			Enumeration apps = l.getAllAppenders();                        
            if ( apps.hasMoreElements() ) {
                
                while (apps.hasMoreElements() ) {
                    Appender app = (Appender) apps.nextElement();
                    // appenders.add(app);
                    if ( l.getName().startsWith("org.apache.uima.ducc") ) {
                        if ( debug ) System.out.println(" ---> Found appender " + app.getName() + " on logger " + l.getName());
                        for ( Logger ll : nonDuccLoggers ) {     // put the appender on the non-Ducc logger
                            if ( debug ) System.out.println(" ---> Add appender " + app.getName() + " to logger " + ll.getName());
                            if ( ll.getAppender(app.getName() ) == null ) {
                                ll.addAppender(app);
                            }
                        }
                    } else {
                        if ( debug ) System.out.println(" ---> Skipping non-DUCC appender " + app.getName() + " on logger " + l.getName());
                    }
                }
            } else {
                if ( debug ) System.out.println(" ---> No appenders on logger " + l.getName());
            }
            l = l.getParent();
        }

    }

    public String getComponent() {
    	return component;
    }
    
    public void setLevel(Level l)
    {
        this.logger.setLevel(l);
    }

    public Level getLevel()
    {
        return logger.getLevel();
    }

    public boolean isLevelEnabled(Level l)
    {
        return l.isGreaterOrEqual(logger.getEffectiveLevel());
    }

    public boolean isFatal() 
    {
        return isLevelEnabled(Level.FATAL);
    }

    public boolean isDebug() 
    {
        return isLevelEnabled(Level.DEBUG);
    }

    public boolean isError() 
    {
        return isLevelEnabled(Level.ERROR);
    }

    public boolean isInfo() 
    {
        return isLevelEnabled(Level.INFO);
    }

    public boolean isWarn() 
    {
        return isLevelEnabled(Level.WARN);
    }

    public boolean isTrace() 
    {
        return isLevelEnabled(Level.TRACE);
    }

    protected String formatMsg(DuccId pid, Object ... args)
    {
    	String header = format(pid);
        String msg = formatMsg(args);
        return header + " " + msg;
    }
    
    private void appendStackTrace(StringBuffer s, Throwable t)
    {
    	s.append("\nAt:\n");
        StackTraceElement[] stacktrace = t.getStackTrace();
        for ( StackTraceElement ste : stacktrace ) {
            s.append("\t");
            s.append(ste.toString());
            s.append("\n");
        }
    }

    protected String formatMsg(Object ... args)
    {
    	StringBuffer s = new StringBuffer();
        for ( Object a : args ) {
            if ( a == null ) a = "<null>"; // avoid null pointers

            s.append(" ");
            if ( a instanceof Throwable ) {
            	Throwable t = (Throwable ) a;
                s.append(t.toString());
                s.append("\n");
                appendStackTrace(s, t);
            } else {                
                s.append(a.toString());
            }
        }
        return s.toString();
    }

    public void setDefaultDuccId(String defaultDuccId) {
    	if(defaultDuccId != null) {
    		defaultId = defaultDuccId;
    	}
    }
    
    private String defaultId = "N/A";
    private final String padding = "                ";  // Max padding needed is 19- 3
    
    // UIMA-5190 Pad the N/A value to match the job #s so headings align correctly
    private String format(DuccId duccId) {
    	String id;
        if ( duccId == null ) {
            id = defaultId;
        } else {
            id = duccId.toString();
            int increase = id.length() - defaultId.length();
            if (increase > 0) {
                defaultId += padding.substring(0, increase);
            }
        }
        return id;
    }
    
    protected void setMDC()
    {
        //MDC.put("COMPONENT", component);
    }

    protected void clearMDC()
    {
        // MDC.clear();
    }

    public void doAppend(Level level, String method, DuccId jobid, String msg, Throwable t)
    {
        DuccLoggingEvent ev = new DuccLoggingEvent(logger, component, level, method, jobid, msg, t, Thread.currentThread().getId(), Thread.currentThread().getName());
        if ( threaded.get() ) {
            events.offer(ev);
        } else {
            doLog(ev);
        }
    }

    public void doAppend(Level level, String method, DuccId jobid, String msg)
    {
        DuccLoggingEvent ev = new DuccLoggingEvent(logger, component, level, method, jobid, msg, null, Thread.currentThread().getId(), Thread.currentThread().getName());
        if ( threaded.get() ) {
            events.offer(ev);
        } else {
            doLog(ev);
        }
    }

    public void fatal(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(args));
        }
    }

    public void fatal(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(args), t);
        }
    }

    public void fatal(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(processId, args));
        }
    }

    public void fatal(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void debug(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(args));
        } 
    }

    public void debug(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(args), t);
        }
    }
    
    public void debug(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(processId, args));
        } 
    }

    public void debug(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void error(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(args));
        }
    }

    public void error(String location, DuccId jobid, Throwable t, Object ... args)
    { 
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(args), t);
        }
    }
    
    public void error(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(processId, args));
        }
    }

    public void error(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    { 
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void info(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(args));
        }
    }

    public void info(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(args), t);
        }
    }
    
    public void info(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(processId, args));
        }
    }

    public void info(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void trace(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(args));
        }
    }

    public void trace(String location, DuccId jobid, Throwable t, Object ... args)
    {    
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(args), t);
        }
    }
    
    public void trace(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(processId, args));
        }
    }

    public void trace(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {    
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void warn(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(args));
        }
    }

    public void warn(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(args), t);
        }
    }
    
    public void warn(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(processId, args));
        }
    }

    public void warn(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(processId, args), t);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/DuccLogger.java [206:580]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        this.logger = Logger.getLogger(claz);
        MDC.put("COMPONENT", component);

        ErrorHandler errHandler = new DuccLogErrorHandler(this);
        @SuppressWarnings("rawtypes")
		Enumeration appenders = logger.getAllAppenders();
        while (appenders.hasMoreElements() ) {
            Appender app = (Appender) appenders.nextElement();
            app.setErrorHandler(errHandler);
        }
    }

    public DuccLogger(@SuppressWarnings("rawtypes") Class claz, String component)
    {
        this(claz.getName(), component);
    }
        
    public DuccLogger(@SuppressWarnings("rawtypes") Class claz)
    {
        this(claz, null);
    }
    
    public DuccLogger(String claz)
    {
        this(claz, null);
    }

    public boolean isDefaultLogger()
    {
        return this.component.equals(DEFAULT_COMPONENT);
    }

    public void setAdditionalAppenders()
    {
    	if ( debug ) System.out.println("============ Looking for appenders -----------");
        if ( isDefaultLogger() ) {
            if ( debug ) System.out.println(" ---> Skipping appender search for default component");
            return;
        }

        Category l = logger;
        // List<Appender> appenders= new ArrayList<Appender>();
        while ( l != null ) {
        	@SuppressWarnings("rawtypes")
			Enumeration apps = l.getAllAppenders();                        
            if ( apps.hasMoreElements() ) {
                
                while (apps.hasMoreElements() ) {
                    Appender app = (Appender) apps.nextElement();
                    // appenders.add(app);
                    if ( l.getName().startsWith("org.apache.uima.ducc") ) {
                        if ( debug ) System.out.println(" ---> Found appender " + app.getName() + " on logger " + l.getName());
                        for ( Logger ll : nonDuccLoggers ) {     // put the appender on the non-Ducc logger
                            if ( debug ) System.out.println(" ---> Add appender " + app.getName() + " to logger " + ll.getName());
                            if ( ll.getAppender(app.getName() ) == null ) {
                                ll.addAppender(app);
                            }
                        }
                    } else {
                        if ( debug ) System.out.println(" ---> Skipping non-DUCC appender " + app.getName() + " on logger " + l.getName());
                    }
                }
            } else {
                if ( debug ) System.out.println(" ---> No appenders on logger " + l.getName());
            }
            l = l.getParent();
        }

    }

    public String getComponent() {
    	return component;
    }
    
    public void setLevel(Level l)
    {
        this.logger.setLevel(l);
    }

    public Level getLevel()
    {
        return logger.getLevel();
    }

    public boolean isLevelEnabled(Level l)
    {
        return l.isGreaterOrEqual(logger.getEffectiveLevel());
    }

    public boolean isFatal() 
    {
        return isLevelEnabled(Level.FATAL);
    }

    public boolean isDebug() 
    {
        return isLevelEnabled(Level.DEBUG);
    }

    public boolean isError() 
    {
        return isLevelEnabled(Level.ERROR);
    }

    public boolean isInfo() 
    {
        return isLevelEnabled(Level.INFO);
    }

    public boolean isWarn() 
    {
        return isLevelEnabled(Level.WARN);
    }

    public boolean isTrace() 
    {
        return isLevelEnabled(Level.TRACE);
    }

    protected String formatMsg(DuccId pid, Object ... args)
    {
    	String header = format(pid);
        String msg = formatMsg(args);
        return header + " " + msg;
    }
    
    private void appendStackTrace(StringBuffer s, Throwable t)
    {
    	s.append("\nAt:\n");
        StackTraceElement[] stacktrace = t.getStackTrace();
        for ( StackTraceElement ste : stacktrace ) {
            s.append("\t");
            s.append(ste.toString());
            s.append("\n");
        }
    }

    protected String formatMsg(Object ... args)
    {
    	StringBuffer s = new StringBuffer();
        for ( Object a : args ) {
            if ( a == null ) a = "<null>"; // avoid null pointers

            s.append(" ");
            if ( a instanceof Throwable ) {
            	Throwable t = (Throwable ) a;
                s.append(t.toString());
                s.append("\n");
                appendStackTrace(s, t);
            } else {                
                s.append(a.toString());
            }
        }
        return s.toString();
    }

    public void setDefaultDuccId(String defaultDuccId) {
    	if(defaultDuccId != null) {
    		defaultId = defaultDuccId;
    	}
    }
    
    private String defaultId = "N/A";
    private final String padding = "                ";  // Max padding needed is 19- 3
    
    // UIMA-5190 Pad the N/A value to match the job #s so headings align correctly
    private String format(DuccId duccId) {
    	String id;
        if ( duccId == null ) {
            id = defaultId;
        } else {
            id = duccId.toString();
            int increase = id.length() - defaultId.length();
            if (increase > 0) {
                defaultId += padding.substring(0, increase);
            }
        }
        return id;
    }
    
    protected void setMDC()
    {
        //MDC.put("COMPONENT", component);
    }

    protected void clearMDC()
    {
        // MDC.clear();
    }

    public void doAppend(Level level, String method, DuccId jobid, String msg, Throwable t)
    {
        DuccLoggingEvent ev = new DuccLoggingEvent(logger, component, level, method, jobid, msg, t, Thread.currentThread().getId(), Thread.currentThread().getName());
        if ( threaded.get() ) {
            events.offer(ev);
        } else {
            doLog(ev);
        }
    }

    public void doAppend(Level level, String method, DuccId jobid, String msg)
    {
        DuccLoggingEvent ev = new DuccLoggingEvent(logger, component, level, method, jobid, msg, null, Thread.currentThread().getId(), Thread.currentThread().getName());
        if ( threaded.get() ) {
            events.offer(ev);
        } else {
            doLog(ev);
        }
    }

    public void fatal(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(args));
        }
    }

    public void fatal(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(args), t);
        }
    }

    public void fatal(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(processId, args));
        }
    }

    public void fatal(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.FATAL) ) {
            doAppend(Level.FATAL, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void debug(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(args));
        } 
    }

    public void debug(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(args), t);
        }
    }
    
    public void debug(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(processId, args));
        } 
    }

    public void debug(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.DEBUG) ) {
            doAppend(Level.DEBUG, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void error(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(args));
        }
    }

    public void error(String location, DuccId jobid, Throwable t, Object ... args)
    { 
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(args), t);
        }
    }
    
    public void error(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(processId, args));
        }
    }

    public void error(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    { 
        if ( isLevelEnabled(Level.ERROR) ) {
            doAppend(Level.ERROR, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void info(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(args));
        }
    }

    public void info(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(args), t);
        }
    }
    
    public void info(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(processId, args));
        }
    }

    public void info(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.INFO) ) {
            doAppend(Level.INFO, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void trace(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(args));
        }
    }

    public void trace(String location, DuccId jobid, Throwable t, Object ... args)
    {    
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(args), t);
        }
    }
    
    public void trace(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(processId, args));
        }
    }

    public void trace(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {    
        if ( isLevelEnabled(Level.TRACE) ) {
            doAppend(Level.TRACE, location, jobid, formatMsg(processId, args), t);
        }
    }
    
    public void warn(String location, DuccId jobid, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(args));
        }
    }

    public void warn(String location, DuccId jobid, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(args), t);
        }
    }
    
    public void warn(String location, DuccId jobid, DuccId processId, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(processId, args));
        }
    }

    public void warn(String location, DuccId jobid, DuccId processId, Throwable t, Object ... args)
    {
        if ( isLevelEnabled(Level.WARN) ) {
            doAppend(Level.WARN, location, jobid, formatMsg(processId, args), t);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



