logs - 如何删除日志文件中的数据库信息

时间:2017-04-05 04:33:52

标签: java spring logging logback ibatis

我在我的项目中使用Spring iBatis Framework。然后使用logback记录im。然后,在检查日志文件后,我可以看到系统正在使用的数据库......出于安全目的,我想隐藏它

以下是示例日志..

var Map = React.createClass({

  render: function() {


    return (
        <div>
            <h2>Country passed from props: {this.props.route.country} </h2>
            <h2>Reptile passed from props: {this.props.route.reptile} </h2>
        </div>
    )

    }

});



export default Map;

logback.xml

12:22:59.585 [http-bio-3088-exec-1] DEBUG org.mybatis.spring.SqlSessionUtils - Creating SqlSession with JDBC Connection [jdbc:postgresql://127.0.0.1:5432/SAMPLEDB, UserName=postgres, PostgreSQL Native Driver]
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.Connection - ooo Connection Opened
12:22:59.585 [http-bio-3088-exec-1] DEBUG o.m.s.t.SpringManagedTransaction - JDBC Connection [jdbc:postgresql://127.0.0.1:5432/SAMPLEDB, UserName=postgres, PostgreSQL Native Driver] will not be managed by Spring
12:22:59.585 [http-bio-3088-exec-1] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@13c8ced] was not registered for synchronization because synchronization is not active
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.PreparedStatement - ==>  Executing: SELECT * (purposely deleted)
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.PreparedStatement - ==> Parameters: ADMIN(String), 0(Integer)
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.ResultSet - <==    Columns: (purposely deleted, list of columns)
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.ResultSet - <==        Row: 86, ADMIN, 1, 7, 0, ADMIN, 20170403, 135432, SCREENID, null, null, null, null, 0, null, 1
12:22:59.585 [http-bio-3088-exec-1] DEBUG org.mybatis.spring.SqlSessionUtils - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@13c8ced]
12:22:59.585 [http-bio-3088-exec-1] DEBUG org.mybatis.spring.SqlSessionUtils - Creating SqlSession with JDBC Connection [jdbc:postgresql://127.0.0.1:5432/SAMPLEDB, UserName=postgres, PostgreSQL Native Driver]
12:22:59.585 [http-bio-3088-exec-1] DEBUG java.sql.Connection - ooo Connection Opened
12:22:59.585 [http-bio-3088-exec-1] DEBUG o.m.s.t.SpringManagedTransaction - JDBC Connection [jdbc:postgresql://127.0.0.1:5432/SAMPLEDB, UserName=postgres, PostgreSQL Native Driver] will not be managed by Spring
12:22:59.585 [http-bio-3088-exec-1] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@18bbc43] was not registered for synchronization because synchronization is not active
12:22:59.601 [http-bio-3088-exec-1] DEBUG java.sql.PreparedStatement - ==>  Executing: SELECT count(*) (purposely deleted)
12:22:59.601 [http-bio-3088-exec-1] DEBUG java.sql.PreparedStatement - ==> Parameters: 1(Integer), 7(BigDecimal), SA(String), 0(Integer), 20170404(Integer), 20170404(Integer)
12:23:00.241 [http-bio-3088-exec-1] DEBUG java.sql.ResultSet - <==    Columns: count
12:23:00.241 [http-bio-3088-exec-1] DEBUG java.sql.ResultSet - <==        Row: 7

我想删除 o.m.s.t.SpringManagedTransaction 部分

3 个答案:

答案 0 :(得分:1)

如果您将root logger更改为levelINFO,则会将其应用于所有软件包,例如,如果您要更改日志记录级别对于所有套餐,您可以更改level上的root

但是,如果您只想单独控制o.m.s.t.SpringManagedTransaction日志记录,则可以通过为该程序包添加logger来执行此操作,如下所示:

<!-- set this level to WARN/ERROR upto your project -->
<logger name="o.m.s.t.SpringManagedTransaction" level="INFO" additivity="false">
    <appender-ref ref="STDOUT"/>
    <appender-ref ref="WINFILE"/>
</logger>

<!-- if you want add more loggers here for different packages -->    

<!-- this is for all other packages -->
<root level="debug">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="WINFILE" />
 </root>

答案 1 :(得分:0)

将根日志级别更改为info。这意味着它不会打印调试日志。

<root level="info">
        <appender-ref ref="STDOUT" />
         <appender-ref ref="WINFILE" />
    </root>

答案 2 :(得分:0)

<root level="info">

或在logback.xml中添加

<logger name="o.m.s.t.SpringManagedTransaction" additivity="false">
  <level value="info"/>
  <appender-ref ref="STDOUT"/>
  <appender-ref ref="WINFILE"/>
</logger>