public static void setupLogger(Config config) throws IOException { Layout layout = new PatternLayout("%d{" + DATE_FORMAT + "} %5p: %m%n"); Appender appender = new DailyRollingFileAppender( layout, config.getString("logger.file"), "'.'yyyyMMdd"); LogManager.resetConfiguration(); LogManager.getRootLogger().addAppender(new NullAppender()); logger = Logger.getLogger(LOGGER_NAME); logger.addAppender(appender); logger.setLevel(Level.toLevel(config.getString("logger.level"), Level.ALL)); // Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem" InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() { @Override public InternalLogger newInstance(String string) { return new NettyInternalLogger(); } }); Log.logSystemInfo(); Log.info("Version: " + getAppVersion()); }
/** * Sets up the verbose and debug mode depending on mvn logging level, and * sets up hyperjaxb logging. */ protected void setupLogging() { super.setupLogging(); final Logger rootLogger = LogManager.getRootLogger(); rootLogger.addAppender(new NullAppender()); final Logger logger = LogManager.getLogger("org.jvnet.hyperjaxb3"); final Log log = getLog(); logger.addAppender(new Appender(getLog(), new PatternLayout( "%m%n %c%n"))); if (this.getDebug()) { log.debug("Logger level set to [debug]."); logger.setLevel(Level.DEBUG); } else if (this.getVerbose()) logger.setLevel(Level.INFO); else if (log.isWarnEnabled()) logger.setLevel(Level.WARN); else logger.setLevel(Level.ERROR); }
/***/ @BeforeClass public static void beforeClass() { if (!DEBUG) { getRootLogger().removeAllAppenders(); getRootLogger().addAppender(new NullAppender()); } }
@BeforeClass public static void setUp() throws Exception { LOGGER.removeAllAppenders(); LOGGER.addAppender(new NullAppender()); index = new SearchResultIndex(PATH, INDEX, 10); SearchResult result = readFile("exampleSearchResult.json"); index.offer(result); index.flush(); }
@BeforeClass public static void setUp() throws Exception { LOGGER.removeAllAppenders(); LOGGER.addAppender(new NullAppender()); engines = new ResourceIndex(PATH, INDEX); Resource engine = searsia(); engines.putMother(engine); }
/** * Constructor used for MySQL * * @param host * @param port * @param database * @param username * @param password * @throws SQLException */ public DataSourceHandler(final String host, final String port, final String database, final String username, final String password) throws SQLException{ // Check database's informations and init connection this.host = Preconditions.checkNotNull(host); this.port = Preconditions.checkNotNull(port); this.database = Preconditions.checkNotNull(database); this.username = Preconditions.checkNotNull(username); this.password = Preconditions.checkNotNull(password); BAT.getInstance().getLogger().config("Initialization of HikariCP in progress ..."); BasicConfigurator.configure(new NullAppender()); ds = new HikariDataSource(); ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database + "?useLegacyDatetimeCode=false&serverTimezone=" + TimeZone.getDefault().getID()); ds.setUsername(this.username); ds.setPassword(this.password); ds.addDataSourceProperty("cachePrepStmts", "true"); ds.setMaximumPoolSize(8); try { final Connection conn = ds.getConnection(); int intOffset = Calendar.getInstance().getTimeZone().getOffset(Calendar.getInstance().getTimeInMillis()) / 1000; String offset = String.format("%02d:%02d", Math.abs(intOffset / 3600), Math.abs((intOffset / 60) % 60)); offset = (intOffset >= 0 ? "+" : "-") + offset; conn.createStatement().executeQuery("SET time_zone='" + offset + "';"); conn.close(); BAT.getInstance().getLogger().config("BoneCP is loaded !"); } catch (final SQLException e) { BAT.getInstance().getLogger().severe("BAT encounters a problem during the initialization of the database connection." + " Please check your logins and database configuration."); if(e.getCause() instanceof CommunicationsException){ BAT.getInstance().getLogger().severe(e.getCause().getMessage()); } if(BAT.getInstance().getConfiguration().isDebugMode()){ BAT.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e); } throw e; } sqlite = false; }
/** * Disables all loggers. */ @BeforeClass public static void init() { // remove all of them Logger.getRootLogger().removeAllAppenders(); Logger.getRootLogger().addAppender(new NullAppender()); final File modelLocation = new File("_data/", "tidaDbMinuteLoadingPerformance"); assertTrue(Files.deleteDir(modelLocation)); }
@Before public void instrumentLoggingForTesting() { loggingEvents.clear(); appender = new NullAppender() { @Override public void doAppend(LoggingEvent event) { loggingEvents.add(event); } }; Logger.getLogger(Appmon4jDumper.class).addAppender(appender); }
/** * Main method * * @param args Program arguments */ public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(new NullAppender()); java.util.logging.Logger.getLogger("org.hibernate").setLevel(OFF); Application.launch(args); }
@BeforeClass public static void configureLogger() throws Exception { BasicConfigurator.configure(new NullAppender()); }
@BeforeClass public static void configureLog4J() { BasicConfigurator.configure(new NullAppender()); }
/** * Simply configure the primary log4j Loggers to send all output to the bit bucket. */ public static void configurePrimaryLoggerToSwallowLogs() { org.apache.log4j.BasicConfigurator.configure(new NullAppender()); }
private void setLoggerDefaultOptions() { org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger(); root.addAppender(new NullAppender()); root.setLevel(Level.INFO); }