The associated source code and log

  • Association Source

      1. Hold down the Ctrl click on the variable type (String \ int ...), click Attach Source, select External location, click External File, went to jdk package can be checked to find src.zip

  • Boot Logging

      2. Add the log dependency in pom.xml dependencies tag code is as follows:

 

 1 <!--  3.1 log4j2的实现类-->
 2     <dependency>
 3         <groupId>org.apache.logging.log4j</groupId>
 4         <artifactId>log4j-core</artifactId>
 5         <version>2.6.2</version>
 6     </dependency>
 7  <!-- 3.2 log4j2到slf4j的驱动类:-->
 8     <dependency>
 9         <groupId>org.apache.logging.log4j</groupId>
10         <artifactId>log4j-slf4j-impl</artifactId>
11         <version>2.6.2</version>
12     </dependency>

 

 

 

      3. Write the src / main / resources named login4j2.xml profile, as follows :

 

<? xml Version = " 1.0 " encoding = " UTF-8 " ?> 
<the Configuration> <-! to this configuration there, in what format the additional log -> 
    <Appenders> 
        <Console name = " STDOUT " target = " SYSTEM_OUT " > 
            < the PatternLayout 
                pattern = " % D% -5p [% T] {2}% C (% F.:% L) -%% n-m " /> 
        </ Console> 
    </ Appenders>      <- control! those log records -> 
    <Loggers is>         <-! a control packet ->
        <Logger name=" org.apache.ibatis
   " Level = " the trace " />
        ! <- This configure the default log level: for example, you specify warn, then it outputs warn, error and fatal level log the trace, Debug, info, 
            warn, error, fatal -> 
        <Root = Level " the trace " > 
            <AppenderRef REF = " STDOUT " /> 
        </ Root> 
    </ Loggers is> 
</ the Configuration>
  • In writing test class, in sqlsession.close () closed at the same time, also need to manually commit the transaction, namely sqlsession.commit ();

 

 

 

Guess you like

Origin www.cnblogs.com/yuanshuai1026/p/11574596.html