Search in sources :

Example 1 with LogFilter

use of com.alibaba.druid.filter.logging.LogFilter in project druid by alibaba.

the class LogFilterTest4 method test_properties_1.

public void test_properties_1() throws Exception {
    System.setProperty("druid.log.conn", "false");
    System.setProperty("druid.log.stmt", "false");
    System.setProperty("druid.log.rs", "false");
    System.setProperty("druid.log.stmt.executableSql", "true");
    try {
        LogFilter filter = new Log4jFilter();
        Assert.assertEquals(false, filter.isConnectionLogEnabled());
        Assert.assertEquals(false, filter.isStatementLogEnabled());
        Assert.assertEquals(true, filter.isStatementExecutableSqlLogEnable());
        Assert.assertEquals(false, filter.isResultSetLogEnabled());
        Properties properties = new Properties();
        properties.setProperty("druid.log.conn", "true");
        properties.setProperty("druid.log.stmt", "true");
        properties.setProperty("druid.log.rs", "true");
        properties.setProperty("druid.log.stmt.executableSql", "false");
        filter.configFromProperties(properties);
        Assert.assertEquals(true, filter.isConnectionLogEnabled());
        Assert.assertEquals(true, filter.isStatementLogEnabled());
        Assert.assertEquals(false, filter.isStatementExecutableSqlLogEnable());
        Assert.assertEquals(true, filter.isResultSetLogEnabled());
    } finally {
        System.clearProperty("druid.log.conn");
        System.clearProperty("druid.log.stmt");
        System.clearProperty("druid.log.rs");
        System.clearProperty("druid.log.stmt.executableSql");
    }
}
Also used : Log4jFilter(com.alibaba.druid.filter.logging.Log4jFilter) Properties(java.util.Properties) LogFilter(com.alibaba.druid.filter.logging.LogFilter)

Example 2 with LogFilter

use of com.alibaba.druid.filter.logging.LogFilter in project druid by alibaba.

the class LogFilterTest4 method test_properties.

public void test_properties() throws Exception {
    LogFilter filter = new Log4jFilter();
    Assert.assertEquals(true, filter.isConnectionLogEnabled());
    Assert.assertEquals(true, filter.isStatementLogEnabled());
    Assert.assertEquals(false, filter.isStatementExecutableSqlLogEnable());
    Assert.assertEquals(true, filter.isResultSetLogEnabled());
}
Also used : Log4jFilter(com.alibaba.druid.filter.logging.Log4jFilter) LogFilter(com.alibaba.druid.filter.logging.LogFilter)

Aggregations

Log4jFilter (com.alibaba.druid.filter.logging.Log4jFilter)2 LogFilter (com.alibaba.druid.filter.logging.LogFilter)2 Properties (java.util.Properties)1