• log4j的使用


    1. 先配置maven

    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
    </dependency>

    2.在下图目录中配置log4j

    # 日记级别(单个级别) 文件/控制台
    log4j.rootLogger=info, stdout,file
    
    # Redirect log messages to console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
    
    # Rirect log messages to a log file
    log4j.appender.file=org.apache.log4j.RollingFileAppender
    log4j.appender.file.File=test.log
    log4j.appender.file.MaxFileSize=5MB
    log4j.appender.file.MaxBackupIndex=10
    log4j.appender.file.layout=org.apache.log4j.PatternLayout
    log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

    3. 使用log4j

    public class Demo_01_base {
        private static final Logger logger = LoggerFactory.getLogger(Demo_01_base.class);
    
        static String accessToken;
        static int departmentId;
        @BeforeAll
        public static void getAccessToken(){
            accessToken = given().log().all()
                    .when()
                    .param("corpid","ww1aa64e79931be685")
                    .param("corpsecret","82N9nLXm5CH7ZtY6LgkWHYPgcS_yQESQXTYD_8iF_Lw")
                    .get("https://qyapi.weixin.qq.com/cgi-bin/gettoken")
                    .then().log().all()
                    .extract().response().path("access_token");
            logger.info(accessToken);
        }
    }
  • 相关阅读:
    Vim基本功
    八个最常用的正则表达式
    程序员总结:帮助你早些明白一些道理
    HttpClient
    Red.Hat.Enterprise.Linux.6.2下安装vim 、OpenOffice、JDK、Eclipse
    输出打印某个对象所有属性及属性值
    Notepad++
    写博客?
    解决操作WordPress时提示输入FTP信息
    JS通过键盘点击事件实现div移动
  • 原文地址:https://www.cnblogs.com/cythia2018/p/14619029.html
Copyright © 2020-2023  润新知