Image via Wikipedia
In order to effectively disable the logging functionality in Apache POI you must use an alternative logger. This is accomplished by providing a property to the POILogFactory
to override the default logger. Examining the partial code from the POILogFactory
, we see that we can pass a logger name into it.public static POILogger getLogger(final String cat) { POILogger logger = null; // If we haven't found out what logger to use yet, // then do so now // Don't look it up until we're first asked, so // that our users can set the system property // between class loading and first use if(_loggerClassName == null) { try { _loggerClassName = System.getProperty("org.apache.poi.util.POILogger");//<<---------- Logger Name } catch(Exception e) {} // Use the default logger if none specified, // or none could be fetched if(_loggerClassName == null) { _loggerClassName = _nullLogger.getClass().getName(); } } ...So we need to simply set the
Logger property which can be accomplished from the command line. We will use the Apache Commons Logging Library to accomplish it.
-Dorg.apache.poi.util.POILogger=org.apache.commons.logging.impl.NoOpLog
0 comments :
Post a Comment