Package org.sf.bee.commons.logging.configuration.elements

Examples of org.sf.bee.commons.logging.configuration.elements.HandlerElement


        for (Map.Entry<String, HandlerElement> entry : handlers.entrySet()) {
            if (null == entry.getValue()) {
                continue;
            }
            // solve handler element looking in cache
            HandlerElement solved = this.solveHandlerElement(entry.getValue());
            // create handler and add to logger
            LogAbstractHandler handler = this.getHandlerInstance(solved);

            if (null != handler) {
                String nativeClassName = handler.getNativeClass().getName();
                // update solved handler in cache
                solved.setNativeClassName(nativeClassName);
                this.addHandlerElementToCache(solved);
                // update local handler in handlers Map
                entry.getValue().setNativeClassName(nativeClassName);
                // first need to close previouse handler
                int closed = this.closeHandler(logger, nativeClassName);
                _logger.log(Level.FINE, String.format("Closed %s handlers of class type '%s'", closed, solved.getClassName()));

                try {

                    // open new handler
                    if (!handler.isOpen()) {
                        // Open handler
                        handler.open();
                    }

                    // add handler to logger
                    if (null != handler.getNative()) {
                        logger.addHandler(handler.getNative());
                    }
                } catch (Throwable t) {
                    _logger.log(Level.WARNING,
                            String.format("Unable to open Handler: %s. Error Message was: %s",
                            entry.getKey(), t.getMessage()));
                }
            } else {
                if (null != solved) {
                    _logger.log(Level.INFO,
                            "Handler not found for element: {0}",
                            solved.toString());
                } else {
                    _logger.log(Level.INFO,
                            "Handler not found for element: {0}",
                            entry.getValue().toString());
                }
View Full Code Here


        return formatter;
    }

    private HandlerElement solveHandlerElement(HandlerElement element) {
        HandlerElement cached = this.getHandlerElement(element.getName());
        // replace hndlElem with cached one.
        if (null != cached) {
            return cached;
        }
        return element;
View Full Code Here

                LoggerElement elem = entry.getValue();
                if (StringUtils.hasText(elem.getName())) {
                    Logger logger = Logger.getLogger(elem.getName());
                    Collection<HandlerElement> handlers = elem.getHandlers().values();
                    for (HandlerElement handler : handlers) {
                        HandlerElement solved = this.solveHandlerElement(handler);
                        this.closeHandler(logger, solved.getNativeClassName());
                    }
                }
            }
        }
    }
View Full Code Here

    private void initHandlersCache(List<XmlNode> handlers) {
        if (null == handlers || handlers.isEmpty()) {
            return;
        }
        for (XmlNode handlerNode : handlers) {
            HandlerElement element = new HandlerElement(handlerNode, _defaultLevel, this.getOutputRoot());
            this.addHandlerElementToCache(element);
        }
    }
View Full Code Here

    }

    private HandlerElement getHandlerElement(XmlNode node) {
        // first search an element in cache.
        synchronized (_handlersElementCache) {
            HandlerElement element = new HandlerElement(node, _defaultLevel, this.getOutputRoot());
            if (_handlersElementCache.containsKey(element.getName())) {
                return _handlersElementCache.get(element.getName());
            } else {
                return element;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.sf.bee.commons.logging.configuration.elements.HandlerElement

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.