当前位置: 首页>>代码示例>>Java>>正文


Java LevelRangeFilter类代码示例

本文整理汇总了Java中org.apache.log4j.varia.LevelRangeFilter的典型用法代码示例。如果您正苦于以下问题:Java LevelRangeFilter类的具体用法?Java LevelRangeFilter怎么用?Java LevelRangeFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LevelRangeFilter类属于org.apache.log4j.varia包,在下文中一共展示了LevelRangeFilter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
	
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:21,代码来源:iBenchDriver.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:GridLog4jCorrectFileNameTest.java

示例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);
}
 
开发者ID:indeedeng,项目名称:imhotep,代码行数:28,代码来源:TestLocalImhotepServiceCore.java

示例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);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:29,代码来源:Client.java

示例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);
}
 
开发者ID:Wikidata,项目名称:QueryAnalysis,代码行数:16,代码来源:LoggingHandler.java

示例6: 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("[%-5p]\t%d\t%c\t%x\t-\t%m%n"));
    LevelRangeFilter levelRangeFilter = new LevelRangeFilter();
    consoleAppender.addFilter(levelRangeFilter);
    consoleAppender.activateOptions();
    Logger.getRootLogger().addAppender(consoleAppender);
}
 
开发者ID:jgonsior,项目名称:AngryProgrammers,代码行数:13,代码来源:LoggingHandler.java

示例7: 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;
}
 
开发者ID:sapirgolan,项目名称:MFIBlocking,代码行数:8,代码来源:Logging.java

示例8: 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();
}
 
开发者ID:Remper,项目名称:sociallink,代码行数:73,代码来源:SimpleStreamCollector.java

示例9: 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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:Log4JLogger.java

示例10: testUnknownUsages

import org.apache.log4j.varia.LevelRangeFilter; //导入依赖的package包/类
/**
 * Testcase for
 * <a href="http://jira.pentaho.com/browse/MONDRIAN-291">
 * Bug MONDRIAN-291, "'unknown usage' messages"</a>.
 */
public void testUnknownUsages() {
    if (!MondrianProperties.instance().ReadAggregates.get()) {
        return;
    }
    final Logger logger = Logger.getLogger(AggTableManager.class);
    propSaver.setAtLeast(logger, org.apache.log4j.Level.WARN);
    final StringWriter sw = new StringWriter();
    final Appender appender =
        new WriterAppender(new SimpleLayout(), sw);
    final LevelRangeFilter filter = new LevelRangeFilter();
    filter.setLevelMin(org.apache.log4j.Level.WARN);
    appender.addFilter(filter);
    logger.addAppender(appender);
    try {
        final TestContext testContext = TestContext.instance().withSchema(
            "<?xml version=\"1.0\"?>\n"
            + "<Schema name=\"FoodMart\">\n"
            + "<Cube name=\"Sales Degen\">\n"
            + "  <Table name=\"sales_fact_1997\">\n"
            + "    <AggExclude pattern=\"agg_c_14_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_05_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_g_ms_pcat_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_ll_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_special_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_03_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_04_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_pl_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_lc_06_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_lc_100_sales_fact_1997\"/>\n"
            + "    <AggName name=\"agg_c_10_sales_fact_1997\">\n"
            + "      <AggFactCount column=\"fact_count\"/>\n"
            + "      <AggMeasure name=\"[Measures].[Store Cost]\" column=\"store_cost\" />\n"
            + "      <AggMeasure name=\"[Measures].[Store Sales]\" column=\"store_sales\" />\n"
            + "     </AggName>\n"
            + "  </Table>\n"
            + "  <Dimension name=\"Time\" type=\"TimeDimension\" foreignKey=\"time_id\">\n"
            + "    <Hierarchy hasAll=\"false\" primaryKey=\"time_id\">\n"
            + "      <Table name=\"time_by_day\"/>\n"
            + "      <Level name=\"Year\" column=\"the_year\" type=\"Numeric\" uniqueMembers=\"true\"\n"
            + "          levelType=\"TimeYears\"/>\n"
            + "      <Level name=\"Quarter\" column=\"quarter\" uniqueMembers=\"false\"\n"
            + "          levelType=\"TimeQuarters\"/>\n"
            + "      <Level name=\"Month\" column=\"month_of_year\" uniqueMembers=\"false\" type=\"Numeric\"\n"
            + "          levelType=\"TimeMonths\"/>\n"
            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "  <Dimension name=\"Time Degenerate\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"time_id\">\n"
            + "      <Level name=\"day\" column=\"time_id\"/>\n"
            + "      <Level name=\"month\" column=\"product_id\" type=\"Numeric\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "</Cube>\n"
            + "</Schema>");
        testContext.assertQueryReturns(
            "select from [Sales Degen]",
            "Axis #0:\n"
            + "{}\n"
            + "225,627.23");
    } finally {
        logger.removeAppender(appender);
    }
    // Note that 'product_id' is NOT one of the columns with unknown usage.
    // It is used as a level in the degenerate dimension [Time Degenerate].
    TestContext.assertEqualsVerbose(
        "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'customer_count' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'month_of_year' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'quarter' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'the_year' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'unit_sales' with unknown usage.\n",
        sw.toString());
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:82,代码来源:SchemaTest.java

示例11: testUnknownUsages1

import org.apache.log4j.varia.LevelRangeFilter; //导入依赖的package包/类
public void testUnknownUsages1() {
    if (!MondrianProperties.instance().ReadAggregates.get()) {
        return;
    }
    final Logger logger = Logger.getLogger(AggTableManager.class);
    propSaver.setAtLeast(logger, org.apache.log4j.Level.WARN);
    final StringWriter sw = new StringWriter();
    final Appender appender =
        new WriterAppender(new SimpleLayout(), sw);
    final LevelRangeFilter filter = new LevelRangeFilter();
    filter.setLevelMin(org.apache.log4j.Level.WARN);
    appender.addFilter(filter);
    logger.addAppender(appender);
    try {
        final TestContext testContext = TestContext.instance().withSchema(
            "<?xml version=\"1.0\"?>\n"
            + "<Schema name=\"FoodMart\">\n"
            + "<Cube name=\"Denormalized Sales\">\n"
            + "  <Table name=\"sales_fact_1997\">\n"
            + "    <AggExclude pattern=\"agg_c_14_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_05_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_g_ms_pcat_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_ll_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_special_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_04_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_pl_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_10_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_lc_06_sales_fact_1997\"/>\n"
            + "    <AggName name=\"agg_l_03_sales_fact_1997\">\n"
            + "      <AggFactCount column=\"fact_count\"/>\n"
            + "      <AggMeasure name=\"[Measures].[Store Cost]\" column=\"store_cost\" />\n"
            + "      <AggMeasure name=\"[Measures].[Store Sales]\" column=\"store_sales\" />\n"
            + "      <AggMeasure name=\"[Measures].[Unit Sales]\" column=\"unit_sales\" />\n"
            + "      <AggLevel name=\"[Customer].[Customer ID]\" column=\"customer_id\" />\n"
            + "      <AggForeignKey factColumn=\"time_id\" aggColumn=\"time_id\" />\n"
            + "     </AggName>\n"
            + "  </Table>\n"
            + "  <Dimension name=\"Time\" type=\"TimeDimension\" foreignKey=\"time_id\">\n"
            + "    <Hierarchy hasAll=\"false\" primaryKey=\"time_id\">\n"
            + "      <Table name=\"time_by_day\"/>\n"
            + "      <Level name=\"Year\" column=\"the_year\" type=\"Numeric\" uniqueMembers=\"true\"\n"
            + "          levelType=\"TimeYears\"/>\n"
            + "      <Level name=\"Quarter\" column=\"quarter\" uniqueMembers=\"false\"\n"
            + "          levelType=\"TimeQuarters\"/>\n"
            + "      <Level name=\"Month\" column=\"month_of_year\" uniqueMembers=\"false\" type=\"Numeric\"\n"
            + "          levelType=\"TimeMonths\"/>\n"
            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "  <Dimension name=\"Customer\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"customer_id\">\n"
            + "      <Level name=\"Customer ID\" column=\"customer_id\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Dimension name=\"Product\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"product_id\">\n"
            + "      <Level name=\"Product ID\" column=\"product_id\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###\"/>\n"
            + "</Cube>\n"
            + "</Schema>");
        testContext.assertQueryReturns(
            "select from [Denormalized Sales]",
            "Axis #0:\n"
            + "{}\n"
            + "225,627.23");
    } finally {
        logger.removeAppender(appender);
    }
    TestContext.assertEqualsVerbose(
        "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_l_03_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'time_id' with unknown usage.\n",
        sw.toString());
}
 
开发者ID:OSBI,项目名称:mondrian,代码行数:79,代码来源:SchemaTest.java

示例12: testUnknownUsages

import org.apache.log4j.varia.LevelRangeFilter; //导入依赖的package包/类
/**
 * Testcase for
 * <a href="http://jira.pentaho.com/browse/MONDRIAN-291">
 * Bug MONDRIAN-291, "'unknown usage' messages"</a>.
 */
public void testUnknownUsages() {
    if (!MondrianProperties.instance().ReadAggregates.get()) {
        return;
    }
    final Logger logger = Logger.getLogger(AggTableManager.class);
    final StringWriter sw = new StringWriter();
    final Appender appender =
        new WriterAppender(new SimpleLayout(), sw);
    final LevelRangeFilter filter = new LevelRangeFilter();
    filter.setLevelMin(Level.WARN);
    appender.addFilter(filter);
    logger.addAppender(appender);
    try {
        TestContext testContext = TestContext.create(
            "<?xml version=\"1.0\"?>\n"
            + "<Schema name=\"FoodMart\">\n"
            + "<Cube name=\"Sales Degen\">\n"
            + "  <Table name=\"sales_fact_1997\">\n"
            + "    <AggExclude pattern=\"agg_c_14_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_05_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_g_ms_pcat_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_ll_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_special_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_03_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_04_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_pl_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_lc_06_sales_fact_1997\"/>\n"
            + "    <AggName name=\"agg_c_10_sales_fact_1997\">\n"
            + "      <AggFactCount column=\"fact_count\"/>\n"
            + "      <AggMeasure name=\"[Measures].[Store Cost]\" column=\"store_cost\" />\n"
            + "      <AggMeasure name=\"[Measures].[Store Sales]\" column=\"store_sales\" />\n"
            + "     </AggName>\n"
            + "  </Table>\n"
            + "  <Dimension name=\"Time\" type=\"TimeDimension\" foreignKey=\"time_id\">\n"
            + "    <Hierarchy hasAll=\"false\" primaryKey=\"time_id\">\n"
            + "      <Table name=\"time_by_day\"/>\n"
            + "      <Level name=\"Year\" column=\"the_year\" type=\"Numeric\" uniqueMembers=\"true\"\n"
            + "          levelType=\"TimeYears\"/>\n"
            + "      <Level name=\"Quarter\" column=\"quarter\" uniqueMembers=\"false\"\n"
            + "          levelType=\"TimeQuarters\"/>\n"
            + "      <Level name=\"Month\" column=\"month_of_year\" uniqueMembers=\"false\" type=\"Numeric\"\n"
            + "          levelType=\"TimeMonths\"/>\n"
            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "  <Dimension name=\"Time Degenerate\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"time_id\">\n"
            + "      <Level name=\"day\" column=\"time_id\"/>\n"
            + "      <Level name=\"month\" column=\"product_id\" type=\"Numeric\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "</Cube>\n"
            + "</Schema>");
        testContext.assertQueryReturns(
            "select from [Sales Degen]",
            "Axis #0:\n"
            + "{}\n"
            + "225,627.23");
    } finally {
        logger.removeAppender(appender);
    }
    // Note that 'product_id' is NOT one of the columns with unknown usage.
    // It is used as a level in the degenerate dimension [Time Degenerate].
    TestContext.assertEqualsVerbose(
        "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'customer_count' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'month_of_year' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'quarter' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'the_year' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_c_10_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'unit_sales' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_lc_100_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'customer_id' with unknown usage.\n"
        + "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_lc_100_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'unit_sales' with unknown usage.\n",
        sw.toString());
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:82,代码来源:SchemaTest.java

示例13: testUnknownUsages1

import org.apache.log4j.varia.LevelRangeFilter; //导入依赖的package包/类
public void testUnknownUsages1() {
    if (!MondrianProperties.instance().ReadAggregates.get()) {
        return;
    }
    final Logger logger = Logger.getLogger(AggTableManager.class);
    final StringWriter sw = new StringWriter();
    final Appender appender =
        new WriterAppender(new SimpleLayout(), sw);
    final LevelRangeFilter filter = new LevelRangeFilter();
    filter.setLevelMin(Level.WARN);
    appender.addFilter(filter);
    logger.addAppender(appender);
    try {
        TestContext testContext = TestContext.create(
            "<?xml version=\"1.0\"?>\n"
            + "<Schema name=\"FoodMart\">\n"
            + "<Cube name=\"Denormalized Sales\">\n"
            + "  <Table name=\"sales_fact_1997\">\n"
            + "    <AggExclude pattern=\"agg_c_14_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_05_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_g_ms_pcat_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_ll_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_special_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_l_04_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_pl_01_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_c_10_sales_fact_1997\"/>\n"
            + "    <AggExclude pattern=\"agg_lc_06_sales_fact_1997\"/>\n"
            + "    <AggName name=\"agg_l_03_sales_fact_1997\">\n"
            + "      <AggFactCount column=\"fact_count\"/>\n"
            + "      <AggMeasure name=\"[Measures].[Store Cost]\" column=\"store_cost\" />\n"
            + "      <AggMeasure name=\"[Measures].[Store Sales]\" column=\"store_sales\" />\n"
            + "      <AggMeasure name=\"[Measures].[Unit Sales]\" column=\"unit_sales\" />\n"
            + "      <AggLevel name=\"[Customer].[Customer ID]\" column=\"customer_id\" />\n"
            + "      <AggForeignKey factColumn=\"time_id\" aggColumn=\"time_id\" />\n"
            + "     </AggName>\n"
            + "  </Table>\n"
            + "  <Dimension name=\"Time\" type=\"TimeDimension\" foreignKey=\"time_id\">\n"
            + "    <Hierarchy hasAll=\"false\" primaryKey=\"time_id\">\n"
            + "      <Table name=\"time_by_day\"/>\n"
            + "      <Level name=\"Year\" column=\"the_year\" type=\"Numeric\" uniqueMembers=\"true\"\n"
            + "          levelType=\"TimeYears\"/>\n"
            + "      <Level name=\"Quarter\" column=\"quarter\" uniqueMembers=\"false\"\n"
            + "          levelType=\"TimeQuarters\"/>\n"
            + "      <Level name=\"Month\" column=\"month_of_year\" uniqueMembers=\"false\" type=\"Numeric\"\n"
            + "          levelType=\"TimeMonths\"/>\n"
            + "    </Hierarchy>\n"
            + "  </Dimension>\n"
            + "  <Dimension name=\"Customer\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"customer_id\">\n"
            + "      <Level name=\"Customer ID\" column=\"customer_id\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Dimension name=\"Product\">\n"
            + "    <Hierarchy hasAll=\"true\" primaryKey=\"product_id\">\n"
            + "      <Level name=\"Product ID\" column=\"product_id\"/>\n"
            + "    </Hierarchy>"
            + "  </Dimension>"
            + "  <Measure name=\"Store Cost\" column=\"store_cost\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Store Sales\" column=\"store_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###.00\"/>\n"
            + "  <Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n"
            + "      formatString=\"#,###\"/>\n"
            + "</Cube>\n"
            + "</Schema>");
        testContext.assertQueryReturns(
            "select from [Denormalized Sales]",
            "Axis #0:\n"
            + "{}\n"
            + "225,627.23");
    } finally {
        logger.removeAppender(appender);
    }
    TestContext.assertEqualsVerbose(
        "WARN - Recognizer.checkUnusedColumns: Candidate aggregate table 'agg_l_03_sales_fact_1997' for fact table 'sales_fact_1997' has a column 'time_id' with unknown usage.\n",
        sw.toString());
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:78,代码来源:SchemaTest.java


注:本文中的org.apache.log4j.varia.LevelRangeFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。