View | Details | Raw Unified | Return to bug 44627
Collapse All | Expand All

(-)src/java/org/apache/poi/util/POILogFactory.java (-13 / +26 lines)
Lines 36-42 Link Here
36
    // map of POILogger instances, with classes as keys
36
    // map of POILogger instances, with classes as keys
37
    private static Map          _loggers = new HashMap();;
37
    private static Map          _loggers = new HashMap();;
38
38
39
    // logger implementation class to use, most often will be null
40
    private static String _loggerClassName = System.getProperty("org.apache.poi.util.POILogger");
39
41
42
    // default logger to use when nothing else is specified
43
    private static  POILogger _defaultLogger = new NullLogger();
44
40
    /**
45
    /**
41
     * construct a POILogFactory.
46
     * construct a POILogFactory.
42
     */
47
     */
Lines 70-94 Link Here
70
    {
75
    {
71
        POILogger logger = null;
76
        POILogger logger = null;
72
77
73
        if (_loggers.containsKey(cat))
78
        if (_loggerClassName == null)
74
        {
79
        {
75
            logger = ( POILogger ) _loggers.get(cat);
80
            // Use the default logger if nothing else is specified
81
            // It is threadsafe and doesn't care about cateogries
82
            logger = _defaultLogger;
76
        }
83
        }
77
        else
84
        else
78
        {
85
        {
79
            try{
86
            // This is not threadsafe, but is only lightly
80
              String loggerClassName = System.getProperty("org.apache.poi.util.POILogger");
87
            // used for debugging poi itself
81
              Class loggerClass = Class.forName(loggerClassName);
88
            if (_loggers.containsKey(cat))
82
              logger = ( POILogger ) loggerClass.newInstance();
89
            {
90
                logger = ( POILogger ) _loggers.get(cat);
83
            }
91
            }
84
            catch(Exception e){
92
            else
85
            
93
            {
86
              logger = new NullLogger();
94
                try{
95
                    Class loggerClass = Class.forName(_loggerClassName);
96
                    logger = ( POILogger ) loggerClass.newInstance();
97
                    logger.initialize(cat);
98
                }
99
                catch(Exception e){
100
                    logger = _defaultLogger;
101
                }
102
                
103
                _loggers.put(cat, logger);
87
            }
104
            }
88
            
89
            logger.initialize(cat);
90
            
91
            _loggers.put(cat, logger);
92
        }
105
        }
93
        return logger;
106
        return logger;
94
    }
107
    }

Return to bug 44627