Package org.apache.avalon.excalibur.logger

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


    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


            final String lmDefaultLoggerName =
                (String) get( m_rootContext, ContextManagerConstants.LOG_CATEGORY, "fortress" );
            final String lmLoggerName = loggerManagerConfig.getAttribute( "logger", "system.logkit" );

            // Setup the Logger Manager
            m_loggerManager = new LogKitLoggerManager( lmDefaultLoggerName, lmLoggerName );

            ContainerUtil.enableLogging( m_loggerManager, getLogger() );
            ContainerUtil.contextualize( m_loggerManager, m_rootContext );
            ContainerUtil.configure( m_loggerManager, loggerManagerConfig );
            ContainerUtil.start( m_loggerManager );
View Full Code Here

        {
            return new SimpleLogKitManager();
        }
        else if( version.equals( "1.1" ) )
        {
            return new LogKitLoggerManager();
        }
        else
        {
            final String message = "Unknown log version specification";
            throw new IllegalArgumentException( message );
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

        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);
        }
        if ( this.portletContext instanceof PortletContextImpl ) {
            subcontext.put("servlet-context", ((PortletContextImpl)this.portletContext).getServletContext());
        }

        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.context = getDir(this.contextDir, "context");
            this.work = getDir(workDir, "working");
            DefaultContext appContext = new DefaultContext();
            appContext.put(Constants.CONTEXT_WORK_DIR, work);

            this.logManager = new LogKitLoggerManager(hierarchy);
            this.logManager.enableLogging(log);

            if (this.logKit != null) {
                final FileInputStream fis = new FileInputStream(logKit);
                final DefaultConfigurationBuilder builder =
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

                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);
                        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

        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

TOP

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

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.