Dullonjiang 2020-08-15
setting设置:logImpl(key) :
<settings> <setting name="logImpl" value="STDOUT_LOGGING"/> </settings>
日志输出:
Logging initialized using ‘class org.apache.ibatis.logging.stdout.StdOutImpl‘ adapter. PooledDataSource forcefully closed/removed all connections. PooledDataSource forcefully closed/removed all connections. PooledDataSource forcefully closed/removed all connections. PooledDataSource forcefully closed/removed all connections. Class not found: org.jboss.vfs.VFS JBoss 6 VFS API is not available in this environment. Class not found: org.jboss.vfs.VirtualFile VFS implementation org.apache.ibatis.io.JBoss6VFS is not valid in this environment. Using VFS adapter org.apache.ibatis.io.DefaultVFS Find JAR URL: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/test-classes/com/saxon/Dao Not a JAR: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/test-classes/com/saxon/Dao Reader entry: UserDaoTest.class Listing file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/test-classes/com/saxon/Dao Find JAR URL: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/test-classes/com/saxon/Dao/UserDaoTest.class Not a JAR: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/test-classes/com/saxon/Dao/UserDaoTest.class Reader entry: ???? 5 ? Find JAR URL: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao Not a JAR: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao Reader entry: UserMapper.class Reader entry: UserMapper.xml Listing file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao Find JAR URL: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao/UserMapper.class Not a JAR: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao/UserMapper.class Reader entry: ???? 5 getUserList ()Ljava/util/List; Signature )()Ljava/util/List<Lcom/saxon/pojo/User;>; getUserID (I)Lcom/saxon/pojo/User; Find JAR URL: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao/UserMapper.xml Not a JAR: file:/D:/IDEAL项目/Saxon_Mybatis/mybatis_01/target/classes/com/saxon/Dao/UserMapper.xml Reader entry: <?xml version="1.0" encoding="UTF-8"?> Checking to see if class com.saxon.Dao.UserDaoTest matches criteria [is assignable to Object] Checking to see if class com.saxon.Dao.UserMapper matches criteria [is assignable to Object] 0406 Opening JDBC Connection Created connection 220695851. Setting autocommit to false on JDBC Connection [] ==> Preparing: select * from mybatis.saxon ==> Parameters: <== Columns: id, user, pwd <== Row: 1, saxon, 1234567 <== Row: 2, saxon, 441564161 <== Total: 2 441564161 [User{id=1, user=‘saxon‘, pwd=‘1234567‘}, User{id=2, user=‘saxon‘, pwd=‘441564161‘}] Resetting autocommit to true on JDBC Connection [] Closing JDBC Connection [] Returned connection 220695851 to pool. Process finished with exit code 0
重要信息:
Opening JDBC Connection Created connection 220695851. Setting autocommit to false on JDBC Connection [] ==> Preparing: select * from mybatis.saxon ==> Parameters: <== Columns: id, user, pwd <== Row: 1, saxon, 1234567 <== Row: 2, saxon, 441564161 <== Total: 2 441564161 [User{id=1, user=‘saxon‘, pwd=‘1234567‘}, User{id=2, user=‘saxon‘, pwd=‘441564161‘}] Resetting autocommit to true on JDBC Connection [] Closing JDBC Connection [] Returned connection 220695851 to pool.
1.先导入包
<!-- https://mvnrepository.com/artifact/log4j/log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
2.setting设置
#将等级为DEBUG的日志信息输出到console和file这两个目的地,console和file的定义在下面的代码 log4j.rootLogger=DEBUG,console,file #控制台输出的相关设置 log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.Target = System.out log4j.appender.console.Threshold=DEBUG log4j.appender.console.layout = org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=[%c]-%m%n #文件输出的相关设置 log4j.appender.file = org.apache.log4j.RollingFileAppender #存储的位置 log4j.appender.file.File=./log/saxon.log #存储的最大大小,超出这个就在生成另一个 log4j.appender.file.MaxFileSize=10mb log4j.appender.file.Threshold=DEBUG log4j.appender.file.layout=org.apache.log4j.PatternLayout #格式 log4j.appender.file.layout.ConversionPattern=[%p][%d{yy-MM-dd}][%c]%m%n #是否追加 log4j.appender.file.Append=false #日志输出级别 log4j.logger.org.mybatis=DEBUG log4j.logger.java.sql=DEBUG log4j.logger.java.sql.Statement=DEBUG log4j.logger.java.sql.ResultSet=DEBUG log4j.logger.java.sql.PreparedStatement=DEBUG
3.测试
import org.apache.log4j.Logger; static Logger logger = Logger.getLogger (UserDaoTest.class); @Test public void testLog4j(){ logger.info ("我是谁"); logger.error ("我是谁"); logger.debug ("我是谁"); }
其他的日志我也不会,慢慢学习中;
自学地址:狂神说Java