Package org.apache.avalon.excalibur.logger

Examples of org.apache.avalon.excalibur.logger.LogKitLoggerManager$OurErrorHandler


            return;
        }

        // Make sure same hierarchy is used
        Hierarchy hier = Hierarchy.getDefaultHierarchy();
        LogKitLoggerManager manager = new LogKitLoggerManager(null, hier, null, null);

        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
        try {
            Configuration c = builder.buildFromFile(cfg);
            Context ctx = new DefaultContext();
            manager.contextualize(ctx);
            manager.configure(c);
        } catch (IllegalArgumentException e) {
            // This happens if the default log-target id-ref specifies a non-existent target
            System.out.println("Error processing logging config " + cfg);
            System.out.println(e.toString());
        } catch (NullPointerException e) {
View Full Code Here


    String cfg = p.getProperty("log_config");
    if (cfg==null) return;
   
    //Make sure same hierarchy is used
    Hierarchy hier = Hierarchy.getDefaultHierarchy();
    LogKitLoggerManager manager = new LogKitLoggerManager(
        null,hier,null,null
        );
   
    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    try {
      Configuration c = builder.buildFromFile(cfg);
      Context ctx = new DefaultContext();
      manager.contextualize(ctx);
        manager.configure(c);
    } catch (IllegalArgumentException e) {
      // This happens if the default log-target id-ref specifies a non-existent target
      System.out.println("Error processing logging config "+cfg);
      System.out.println(e.toString());
    } catch (NullPointerException e) {
View Full Code Here

            return;
        }

        // Make sure same hierarchy is used
        Hierarchy hier = Hierarchy.getDefaultHierarchy();
        LogKitLoggerManager manager = new LogKitLoggerManager(null, hier, null, null);

        DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
        try {
            Configuration c = builder.buildFromFile(cfg);
            Context ctx = new DefaultContext();
            manager.contextualize(ctx);
            manager.configure(c);
        } catch (IllegalArgumentException e) {
            // This happens if the default log-target id-ref specifies a non-existent target
            System.out.println("Error processing logging config " + cfg);
            System.out.println(e.toString());
        } catch (NullPointerException e) {
View Full Code Here

        Deprecation.setForbiddenLevel(Deprecation.LogLevel.getLevel(deprecationLevel));
    }

    private LoggerManager newLoggerManager(String loggerManagerClass, Hierarchy hierarchy) {
        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
            return new LogKitLoggerManager(hierarchy);
        } else if (loggerManagerClass.equals(Log4JLoggerManager.class.getName()) ||
                   loggerManagerClass.equalsIgnoreCase("LOG4J")) {
            return new Log4JLoggerManager();
        } else {
            try {
                Class clazz = Class.forName(loggerManagerClass);
                return (LoggerManager)clazz.newInstance();
            } catch (Exception e) {
                return new LogKitLoggerManager(hierarchy);
            }
        }
    }
View Full Code Here

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();

        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));

        final LogKitLoggerManager logKitLoggerManager = new LogKitLoggerManager(defaultHierarchy);
        logKitLoggerManager.enableLogging(logger);

        final DefaultContext subcontext = new DefaultContext();
        subcontext.put(Constants.CONTEXT_WORK_DIR, workDir);
        subcontext.put("portlet-context", this.portletContext);
        if (this.portletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (getLogger().isWarnEnabled()) {
                getLogger().warn("Setting context-root for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.portletContextPath);
        }

        try {
            logKitLoggerManager.contextualize(subcontext);

            //Configure the logkit management
            String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");

            // test if this is a qualified url
            InputStream is = null;
            if (logkitConfig.indexOf(':') == -1) {
                is = this.portletContext.getResourceAsStream(logkitConfig);
                if (is == null) is = new FileInputStream(logkitConfig);
            } else {
                URL logkitURL = new URL(logkitConfig);
                is = logkitURL.openStream();
            }
            final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
            final Configuration conf = builder.build(is);
            logKitLoggerManager.configure(conf);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (accesslogger != null) {
            this.log = logKitLoggerManager.getLoggerForCategory(accesslogger);
        } else {
            this.log = logKitLoggerManager.getLoggerForCategory("cocoon");
        }
    }
View Full Code Here

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }

    private LoggerManager newLoggerManager(String loggerManagerClass, Hierarchy hierarchy) {
        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
            return new LogKitLoggerManager(hierarchy);
        } else if (loggerManagerClass.equals(Log4JLoggerManager.class.getName()) ||
                   loggerManagerClass.equalsIgnoreCase("LOG4J")) {
            return new Log4JLoggerManager();
        } else {
            try {
                Class clazz = Class.forName(loggerManagerClass);
                return (LoggerManager)clazz.newInstance();
            } catch (Exception e) {
                return new LogKitLoggerManager(hierarchy);
            }
        }
    }
View Full Code Here

      return;
    }

    // Make sure same hierarchy is used
    Hierarchy hier = Hierarchy.getDefaultHierarchy();
    LogKitLoggerManager manager = new LogKitLoggerManager(null, hier, null, null);

    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
    try {
      Configuration c = builder.buildFromFile(cfg);
      Context ctx = new DefaultContext();
      manager.contextualize(ctx);
      manager.configure(c);
    } catch (IllegalArgumentException e) {
      // This happens if the default log-target id-ref specifies a non-existent target
      System.out.println("Error processing logging config " + cfg);
      System.out.println(e.toString());
    } catch (NullPointerException e) {
View Full Code Here

        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final LogKitLoggerManager logKitLoggerManager = new LogKitLoggerManager(defaultHierarchy);
        logKitLoggerManager.enableLogging(logger);
        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("portlet-context", this.portletContext);
        if (this.portletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting servlet-context for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.portletContextPath);
        }

        try {
            logKitLoggerManager.contextualize(subcontext);
            this.loggerManager = logKitLoggerManager;

            //Configure the logkit management
            String logkitConfig = getInitParameter("logkit-config", "/WEB-INF/logkit.xconf");

            // test if this is a qualified url
            InputStream is = null;
            if (logkitConfig.indexOf(':') == -1) {
                is = this.portletContext.getResourceAsStream(logkitConfig);
                if (is == null) is = new FileInputStream(logkitConfig);
            } else {
                URL logkitURL = new URL(logkitConfig);
                is = logkitURL.openStream();
            }
            final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
            final Configuration conf = builder.build(is);
            logKitLoggerManager.configure(conf);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        if (accesslogger != null) {
            this.log = logKitLoggerManager.getLoggerForCategory(accesslogger);
        } else {
            this.log = logKitLoggerManager.getLoggerForCategory("cocoon");
        }
    }
View Full Code Here

                if (logKit != null) {
                    try {
                        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                        final Configuration logKitConf = builder.buildFromFile(logKit);
                        this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());

                        final DefaultContext subcontext = new DefaultContext(this.ctx);
                        File contextDir = (File) this.ctx.get("context-root");
                        subcontext.put("context-root", contextDir);
                        this.logKitLoggerManager.contextualize(subcontext);
                        this.logKitLoggerManager.configure(logKitConf);
                        logger = this.logKitLoggerManager.getLoggerForCategory(logKitLogCategory);
                    } catch (Exception e) {
                        getLogger().error("Cannot initialize log-kit-manager from logkit-xconf " + String.valueOf(logKit));
                        // clean logKitLoggerManager, try init it without the logkit-xconf
                        this.logKitLoggerManager = null;
                    }
                }
            }

            if (this.logKitLoggerManager == null) {
                this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
                this.logKitLoggerManager.enableLogging(logger);
            }
        }
View Full Code Here

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }

    private LoggerManager newLoggerManager(String loggerManagerClass, Hierarchy hierarchy) {
        if (loggerManagerClass.equals(LogKitLoggerManager.class.getName())) {
            return new LogKitLoggerManager(hierarchy);
        } else if (loggerManagerClass.equals(Log4JLoggerManager.class.getName()) ||
                   loggerManagerClass.equalsIgnoreCase("LOG4J")) {
            return new Log4JLoggerManager();
        } else {
            try {
                Class clazz = Class.forName(loggerManagerClass);
                return (LoggerManager)clazz.newInstance();
            } catch (Exception e) {
                return new LogKitLoggerManager(hierarchy);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.avalon.excalibur.logger.LogKitLoggerManager$OurErrorHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.