本文整理汇总了Java中org.apache.log4j.varia.LevelRangeFilter.setLevelMax方法的典型用法代码示例。如果您正苦于以下问题:Java LevelRangeFilter.setLevelMax方法的具体用法?Java LevelRangeFilter.setLevelMax怎么用?Java LevelRangeFilter.setLevelMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.varia.LevelRangeFilter
的用法示例。
在下文中一共展示了LevelRangeFilter.setLevelMax方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpExperimentalLogger
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
private static void setUpExperimentalLogger(File pathF) throws IOException {
Logger.getRootLogger().removeAllAppenders();
log.removeAllAppenders();
PropertyConfigurator.configure("resource/log4jproperties.txt");
FileAppender resultAppender = new FileAppender(
new PatternLayout("%m"),
new File(pathF, "result.txt").toString(), false);
LevelRangeFilter infoFilter = new LevelRangeFilter();
infoFilter.setLevelMin(Level.INFO);
infoFilter.setLevelMax(Level.FATAL);
infoFilter.setAcceptOnMatch(true);
resultAppender.addFilter(infoFilter);
log.addAppender(resultAppender);
Logger.getLogger(iBench.class).addAppender(resultAppender);
}
示例2: createAppender
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
/**
* Creates new GridLog4jRollingFileAppender.
*
* @return GridLog4jRollingFileAppender.
* @throws Exception If error occurred.
*/
private static Log4jRollingFileAppender createAppender() throws Exception {
Log4jRollingFileAppender appender = new Log4jRollingFileAppender();
appender.setLayout(new PatternLayout("[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"));
appender.setFile("work/log/ignite.log");
appender.setName(Log4jRollingFileAppender.class.getSimpleName());
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.DEBUG);
lvlFilter.setLevelMax(Level.INFO);
appender.addFilter(lvlFilter);
return appender;
}
示例3: initLog4j
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
@BeforeClass
public static void initLog4j() {
BasicConfigurator.resetConfiguration();
BasicConfigurator.configure();
final Layout LAYOUT = new PatternLayout("[ %d{ISO8601} %-5p ] [%c{1}] %m%n");
LevelRangeFilter ERROR_FILTER = new LevelRangeFilter();
ERROR_FILTER.setLevelMin(Level.ERROR);
ERROR_FILTER.setLevelMax(Level.FATAL);
// everything including ERROR
final Appender STDOUT = new ConsoleAppender(LAYOUT, ConsoleAppender.SYSTEM_OUT);
// just things <= ERROR
final Appender STDERR = new ConsoleAppender(LAYOUT, ConsoleAppender.SYSTEM_ERR);
STDERR.addFilter(ERROR_FILTER);
final Logger ROOT_LOGGER = Logger.getRootLogger();
ROOT_LOGGER.removeAllAppenders();
ROOT_LOGGER.setLevel(Level.WARN); // don't care about higher
ROOT_LOGGER.addAppender(STDOUT);
ROOT_LOGGER.addAppender(STDERR);
}
示例4: initializeLogging
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
/**
* Sets up Log4J to write log messages to the console. Low-priority messages
* are logged to stdout while high-priority messages go to stderr.
*/
private void initializeLogging() {
// Since logging is static, make sure this is done only once even if
// multiple clients are created (e.g., during tests)
if (consoleAppender != null) {
return;
}
consoleAppender = new ConsoleAppender();
consoleAppender.setLayout(new PatternLayout(LOG_PATTERN));
consoleAppender.setThreshold(Level.INFO);
LevelRangeFilter filter = new LevelRangeFilter();
filter.setLevelMin(Level.TRACE);
filter.setLevelMax(Level.INFO);
consoleAppender.addFilter(filter);
consoleAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(consoleAppender);
errorAppender = new ConsoleAppender();
errorAppender.setLayout(new PatternLayout(LOG_PATTERN));
errorAppender.setThreshold(Level.WARN);
errorAppender.setTarget(ConsoleAppender.SYSTEM_ERR);
errorAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(errorAppender);
}
示例5: initConsoleLog
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
/**
* Defines an appender that writes INFO log messages to the console.
*/
public static void initConsoleLog()
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setName("ConsoleLogger");
consoleAppender.setLayout(new PatternLayout(" [%p] %d [%t] %x %c %M - %m%n"));
LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
levelRangeFilter.setLevelMax(Level.INFO);
levelRangeFilter.setLevelMin(Level.INFO);
consoleAppender.addFilter(levelRangeFilter);
consoleAppender.activateOptions();
Logger.getRootLogger().addAppender(consoleAppender);
}
示例6: createFilter
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
public LevelRangeFilter createFilter(Level level) {
LevelRangeFilter rangeFilter = new LevelRangeFilter();
rangeFilter.setLevelMin(level);
rangeFilter.setLevelMax(Level.FATAL);
rangeFilter.setAcceptOnMatch(true);
return rangeFilter;
}
示例7: main
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
public static void main(String[] args) throws TwitterException {
PatternLayout layoutStandard = new PatternLayout();
layoutStandard.setConversionPattern("[%p] %d %c %M - %m%n");
PatternLayout layoutSimple = new PatternLayout();
layoutSimple.setConversionPattern("%m%n");
// Filter for the statuses: we only want INFO messages
LevelRangeFilter filter = new LevelRangeFilter();
filter.setLevelMax(Level.INFO);
filter.setLevelMin(Level.INFO);
filter.setAcceptOnMatch(true);
filter.activateOptions();
TimeBasedRollingPolicy statusesRollingPolicy = new TimeBasedRollingPolicy();
statusesRollingPolicy.setFileNamePattern("statuses.log" + HOUR_ROLL);
statusesRollingPolicy.activateOptions();
RollingFileAppender statusesAppender = new RollingFileAppender();
statusesAppender.setRollingPolicy(statusesRollingPolicy);
statusesAppender.addFilter(filter);
statusesAppender.setLayout(layoutSimple);
statusesAppender.activateOptions();
TimeBasedRollingPolicy warningsRollingPolicy = new TimeBasedRollingPolicy();
warningsRollingPolicy.setFileNamePattern("warnings.log" + HOUR_ROLL);
warningsRollingPolicy.activateOptions();
RollingFileAppender warningsAppender = new RollingFileAppender();
warningsAppender.setRollingPolicy(statusesRollingPolicy);
warningsAppender.setThreshold(Level.WARN);
warningsAppender.setLayout(layoutStandard);
warningsAppender.activateOptions();
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.setThreshold(Level.WARN);
consoleAppender.setLayout(layoutStandard);
consoleAppender.activateOptions();
// configures the root logger
Logger rootLogger = Logger.getRootLogger();
rootLogger.setLevel(Level.INFO);
rootLogger.removeAllAppenders();
rootLogger.addAppender(consoleAppender);
rootLogger.addAppender(statusesAppender);
rootLogger.addAppender(warningsAppender);
// creates a custom logger and log messages
final Logger logger = Logger.getLogger(SimpleStreamCollector.class);
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
RawStreamListener rawListener = new RawStreamListener() {
@Override
public void onMessage(String rawString) {
cnt++;
logger.info(rawString);
if (cnt % 1000 == 0) {
System.out.println(cnt + " messages received.");
}
}
@Override
public void onException(Exception ex) {
logger.warn(ex);
}
};
twitterStream.addListener(rawListener);
twitterStream.sample();
}
示例8: createConsoleAppender
import org.apache.log4j.varia.LevelRangeFilter; //导入方法依赖的package包/类
/**
* Creates console appender with some reasonable default logging settings.
*
* @param maxLevel Max logging level.
* @return New console appender.
*/
private Appender createConsoleAppender(Level maxLevel) {
String fmt = "[%d{ISO8601}][%-5p][%t][%c{1}] %m%n";
// Configure output that should go to System.out
Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.TRACE);
lvlFilter.setLevelMax(maxLevel);
app.addFilter(lvlFilter);
return app;
}