org.apache.log4j.varia.NullAppender Java Examples

The following examples show how to use org.apache.log4j.varia.NullAppender. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Hyperjaxb3Mojo.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: MockTest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/***/
@BeforeClass
public static void beforeClass() {
	if (!DEBUG) {
		getRootLogger().removeAllAppenders();
		getRootLogger().addAppender(new NullAppender());
	}
}
 
Example #3
Source File: AbstractImportAndReadSmokeTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotUtils.initialize();

    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    SWTBotUtils.switchToTracingPerspective();
    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}
 
Example #4
Source File: CtfTmfExperimentTrimmingTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Setup before the test suite
 *
 * @throws IOException
 *             failed to load the file
 */
@BeforeClass
public static void beforeClass() throws IOException {
    SWTBotUtils.initialize();

    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());

    File parentDir = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.TRACE_EXPERIMENT.getTraceURL()));
    File[] traceFiles = parentDir.listFiles();
    ITmfTrace traceValidator = new CtfTmfTrace();
    fBot = new SWTWorkbenchBot();
    SWTBotUtils.createProject(PROJECT_NAME);

    int openedTraces = 0;
    for (File traceFile : traceFiles) {
        String absolutePath = traceFile.getAbsolutePath();
        if (traceValidator.validate(null, absolutePath).isOK()) {
            SWTBotUtils.openTrace(PROJECT_NAME, absolutePath, TRACE_TYPE);
            fBot.closeAllEditors();
            openedTraces++;
            if (openedTraces >= NUM_TRACES) {
                break;
            }
        }
    }
    traceValidator.dispose();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}
 
Example #5
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTBotUtils.initialize();
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();

    importProfiles();
}
 
Example #6
Source File: AbstractPerspectiveChecker.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void beforeInit() {
    SWTBotUtils.initialize();

    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 50000; /* 50 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    SWTBotUtils.closeView("welcome", fBot);

}
 
Example #7
Source File: AbstractStandardImportWizardTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Class setup
 */
@BeforeClass
public static void init() {
    SWTBotUtils.initialize();
    fBot = new SWTWorkbenchBot();
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
}
 
Example #8
Source File: RawTextEditorTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTBotUtils.initialize();
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}
 
Example #9
Source File: TestRefreshTextTrace.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/** Test Class setup */
@BeforeClass
public static void init() {
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    SWTBotUtils.initialize();
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new NullAppender());
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
}
 
Example #10
Source File: DataSourceHandler.java    From BungeeAdminTools with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: SFTPFileSystemLoggingTest.java    From sftp-fs with Apache License 2.0 4 votes vote down vote up
@BeforeEach
public void setupAppender() {
    appender = spy(new NullAppender());
    logger.addAppender(appender);
}
 
Example #12
Source File: ClientJobStateTest.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
@BeforeClass
public static void configureLogger() throws Exception {
    BasicConfigurator.configure(new NullAppender());
}
 
Example #13
Source File: DataSpaceNodeConfigurationAgentTest.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
@BeforeClass
public static void configureLog4J() {
    BasicConfigurator.configure(new NullAppender());
}
 
Example #14
Source File: RRDSigarDataStoreTest.java    From scheduling with GNU Affero General Public License v3.0 4 votes vote down vote up
@BeforeClass
public static void configureLog4J() {
    BasicConfigurator.configure(new NullAppender());
}
 
Example #15
Source File: AutoLog.java    From Word2VecJava with MIT License 4 votes vote down vote up
private static boolean init() {
	if (!Logger.getRootLogger().getAllAppenders().hasMoreElements())
		Logger.getRootLogger().addAppender(new NullAppender());
	return true;
}
 
Example #16
Source File: HaxeDebugLogger.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
/**
 * 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());
}