Package org.apache.log

Examples of org.apache.log.ErrorHandler


        if ( hierarchy == null )
        {
            m_hierarchy = new Hierarchy();
            m_hierarchy.getRootLogger().unsetLogTargets( true );
            final ErrorHandler errorHandler = new OurErrorHandler( getLogger() );
            m_hierarchy.setErrorHandler( errorHandler );
        }
        else
        {
            m_hierarchy = hierarchy;
View Full Code Here


        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final ServletOutputLogTarget servTarget = new ServletOutputLogTarget(this.servletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, logger);

        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("servlet-context", this.servletContext);
        subcontext.put("context-work", this.workDir);
        if (this.servletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting context-root for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.servletContextPath);
        }

        try {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
                //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.servletContext.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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.servletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

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

        final String deprecationLevel = getInitParameter("forbidden-deprecation-level", "ERROR");
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final PortletOutputLogTarget servTarget = new PortletOutputLogTarget(this.portletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, 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 (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 {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
            //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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.portletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }
View Full Code Here

        if ( hierarchy == null )
        {
            m_hierarchy = new Hierarchy();
            m_hierarchy.getRootLogger().unsetLogTargets( true );
            final ErrorHandler errorHandler = new OurErrorHandler( getLogger() );
            m_hierarchy.setErrorHandler( errorHandler );
        }
        else
        {
            m_hierarchy = hierarchy;
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final PortletOutputLogTarget servTarget = new PortletOutputLogTarget(this.portletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, 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 (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 {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
            //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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.portletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final ServletOutputLogTarget servTarget = new ServletOutputLogTarget(this.servletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, logger);

        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("servlet-context", this.servletContext);
        subcontext.put("context-work", this.workDir);
        if (this.servletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting context-root for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.servletContextPath);
        }

        try {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
                //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.servletContext.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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.servletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

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

        final String deprecationLevel = getInitParameter("forbidden-deprecation-level", "ERROR");
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final PortletOutputLogTarget servTarget = new PortletOutputLogTarget(this.portletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, 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 (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 {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
            //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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.portletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final ServletOutputLogTarget servTarget = new ServletOutputLogTarget(this.servletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, logger);

        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("servlet-context", this.servletContext);
        subcontext.put("context-work", this.workDir);
        if (this.servletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting context-root for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.servletContextPath);
        }

        try {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
                //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.servletContext.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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.servletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

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

        final String deprecationLevel = getInitParameter("forbidden-deprecation-level", "ERROR");
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final PortletOutputLogTarget servTarget = new PortletOutputLogTarget(this.portletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, 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 (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 {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
            //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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.portletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }
View Full Code Here

        formatter.setFormat("%7.7{priority} %{time}   [%8.8{category}] " +
                            "(%{uri}) %{thread}/%{class:short}: %{message}\\n%{throwable}");
        final ServletOutputLogTarget servTarget = new ServletOutputLogTarget(this.servletContext, formatter);

        final Hierarchy defaultHierarchy = Hierarchy.getDefaultHierarchy();
        final ErrorHandler errorHandler = new DefaultErrorHandler();
        defaultHierarchy.setErrorHandler(errorHandler);
        defaultHierarchy.setDefaultLogTarget(servTarget);
        defaultHierarchy.setDefaultPriority(logPriority);
        final Logger logger = new LogKitLogger(Hierarchy.getDefaultHierarchy().getLoggerFor(""));
        final String loggerManagerClass =
            this.getInitParameter("logger-class", LogKitLoggerManager.class.getName());

        // the log4j support requires currently that the log4j system is already configured elsewhere

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, logger);

        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("servlet-context", this.servletContext);
        subcontext.put("context-work", this.workDir);
        if (this.servletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting context-root for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.servletContextPath);
        }

        try {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;

            if (loggerManager instanceof Configurable) {
                //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.servletContext.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);
                ContainerUtil.configure(loggerManager, conf);
            }

            // let's configure log4j
            final String log4jConfig = getInitParameter("log4j-config", null);
            if ( log4jConfig != null ) {
                final Log4JConfigurator configurator = new Log4JConfigurator(subcontext);

                // test if this is a qualified url
                InputStream is = null;
                if ( log4jConfig.indexOf(':') == -1) {
                    is = this.servletContext.getResourceAsStream(log4jConfig);
                    if (is == null) is = new FileInputStream(log4jConfig);
                } else {
                    final URL log4jURL = new URL(log4jConfig);
                    is = log4jURL.openStream();
                }
                configurator.doConfigure(is, LogManager.getLoggerRepository());
            }

            ContainerUtil.initialize(loggerManager);
        } catch (Exception e) {
            errorHandler.error("Could not set up Cocoon Logger, will use screen instead", e, null);
        }

        this.log = this.loggerManager.getLoggerForCategory(accesslogger);
    }
View Full Code Here

TOP

Related Classes of org.apache.log.ErrorHandler

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.