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());
}
java类org.apache.log4j.varia.NullAppender的实例源码
Log.java 文件源码
项目:traccar-service
阅读 28
收藏 0
点赞 0
评论 0
Hyperjaxb3Mojo.java 文件源码
项目:hyperjaxb3
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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);
}
MockTest.java 文件源码
项目:n4js
阅读 17
收藏 0
点赞 0
评论 0
/***/
@BeforeClass
public static void beforeClass() {
if (!DEBUG) {
getRootLogger().removeAllAppenders();
getRootLogger().addAppender(new NullAppender());
}
}
TestSearchResultIndex.java 文件源码
项目:searsiaserver
阅读 19
收藏 0
点赞 0
评论 0
@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();
}
TestResourceIndex.java 文件源码
项目:searsiaserver
阅读 20
收藏 0
点赞 0
评论 0
@BeforeClass
public static void setUp() throws Exception {
LOGGER.removeAllAppenders();
LOGGER.addAppender(new NullAppender());
engines = new ResourceIndex(PATH, INDEX);
Resource engine = searsia();
engines.putMother(engine);
}
DataSourceHandler.java 文件源码
项目:BungeeAdminTools
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
TestLoadingPerformance.java 文件源码
项目:dis-timeintervaldataanalyzer
阅读 19
收藏 0
点赞 0
评论 0
/**
* 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));
}
Appmon4jDumperTest.java 文件源码
项目:appmon4j
阅读 22
收藏 0
点赞 0
评论 0
@Before
public void instrumentLoggingForTesting() {
loggingEvents.clear();
appender = new NullAppender() {
@Override
public void doAppend(LoggingEvent event) {
loggingEvents.add(event);
}
};
Logger.getLogger(Appmon4jDumper.class).addAppender(appender);
}
App.java 文件源码
项目:HTWK_Visu
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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);
}
ClientJobStateTest.java 文件源码
项目:scheduling
阅读 21
收藏 0
点赞 0
评论 0
@BeforeClass
public static void configureLogger() throws Exception {
BasicConfigurator.configure(new NullAppender());
}
DataSpaceNodeConfigurationAgentTest.java 文件源码
项目:scheduling
阅读 16
收藏 0
点赞 0
评论 0
@BeforeClass
public static void configureLog4J() {
BasicConfigurator.configure(new NullAppender());
}
RRDSigarDataStoreTest.java 文件源码
项目:scheduling
阅读 18
收藏 0
点赞 0
评论 0
@BeforeClass
public static void configureLog4J() {
BasicConfigurator.configure(new NullAppender());
}
HaxeDebugLogger.java 文件源码
项目:intellij-haxe
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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());
}
Yolo.java 文件源码
项目:yolo
阅读 20
收藏 0
点赞 0
评论 0
private void setLoggerDefaultOptions()
{
org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger();
root.addAppender(new NullAppender());
root.setLevel(Level.INFO);
}