• loadrunner11 :脚本日志打印设置及举例说明


    日志打印设置:

    【Vuser】——【Run Time Settings】——【General】——【Log】

    1、【Enable logging】启动日志功能;(建议运行场景进行负载测试时关闭此项)

    2、【Send messages only when an error occurs】仅发送出错时的日志,可设置缓存大小(默认1KB);

    3、【Always send message】发送所有日志;

    4、【Standard log】标准日志,脚本运行时发送函数信息;

    【Extended log】扩展日志:【具体举例看下文】

    5、【Parameter substitution】脚本运行时,在【Replay log】显示参数信息、参数值;

    6、【Data returned by server】记录服务器返回的所有数据;

    7、【Advanced trace】多用于脚本调试,记录VU在运行期间发送的所有函数信息。

    ========================================

    【Replay log】显示的日志颜色:

    1、红色:错误信息;

    2、橙色:迭代信息;

    3、蓝色:事件信息;

    4、黑色:输出信息;

    5、绿色:字符信息。

    ========================================

    输出函数:

    1、lr_log_message()    // 输出信息,并记录到 output.txt 中

    2、lr_output_message()    // 输出信息,不记录到日志文件中

    3、lr_message()    // 输出信息,不记录到日志文件中

    4、lr_error_message()    // 输出信息,不记录到日志文件中

    示例脚本:

    Action()
    {
    
        web_url("chunk-commons.a823364d.css", 
            "URL=http://10.10.10.10:7924/smartCT/static/css/chunk-commons.a823364d.css", 
            "Resource=1", 
            "RecContentType=text/css", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t46.inf", 
            LAST);
    
        web_url("chunk-e799bb7e.4801a3a7.js", 
            "URL=http://10.10.10.10:7924/smartCT/static/js/chunk-e799bb7e.4801a3a7.js", 
            "Resource=1", 
            "RecContentType=application/javascript", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t47.inf", 
            LAST);
    
        web_url("chunk-commons.49852117.js", 
            "URL=http://10.10.10.10:7924/smartCT/static/js/chunk-commons.49852117.js", 
            "Resource=1", 
            "RecContentType=application/javascript", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t48.inf", 
            LAST);
    
        web_url("chunk-1e5fa942.5400010f.js", 
            "URL=http://10.10.10.10:7924/smartCT/static/js/chunk-1e5fa942.5400010f.js", 
            "Resource=1", 
            "RecContentType=application/javascript", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t49.inf", 
            LAST);
    
        web_url("chunk-449fbede.4b200a53.js", 
            "URL=http://10.10.10.10:7924/smartCT/static/js/chunk-449fbede.4b200a53.js", 
            "Resource=1", 
            "RecContentType=application/javascript", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t50.inf", 
            LAST);
    
        web_url("chunk-449fbede.abc36edf.css", 
            "URL=http://10.10.10.10:7924/smartCT/static/css/chunk-449fbede.abc36edf.css", 
            "Resource=1", 
            "RecContentType=text/css", 
            "Referer=http://10.10.10.10:7924/smartCT/3/portal/index.html", 
            "Snapshot=t51.inf", 
            LAST);
    
        web_url("null.5686200b.png", 
            "URL=http://10.10.10.10:7924/smartCT/static/img/null.5686200b.png", 
            "Resource=1", 
            "RecContentType=image/png", 
            "Referer=http://10.10.10.10:7924/smartCT/3/draft/approve", 
            "Snapshot=t52.inf", 
            LAST);
    
        web_url("firstPage", 
            "URL=http://10.10.10.10:7924/alpha/definition/busiSetting/firstPage", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/3/draft/approve", 
            "Snapshot=t53.inf", 
            "Mode=HTML", 
            EXTRARES, 
            "Url=/smartCT/static/css/chunk-7e1d5118.a75ca143.css", "Referer=http://10.10.10.10:7924/smartCT/3/draft/approve", ENDITEM, 
            "Url=/smartCT/static/js/chunk-7e1d5118.dca7d8ad.js", "Referer=http://10.10.10.10:7924/smartCT/3/draft/approve", ENDITEM, 
            LAST);
    
        web_custom_request("customForm", 
            "URL=http://10.10.10.10:7924/alpha/definition/createForm/query/customForm", 
            "Method=POST", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", 
            "Snapshot=t54.inf", 
            "Mode=HTML", 
            "EncType=application/json;charset=utf-8", 
            "Body={"busiId":198,"officeType":"1002","busiType":"2004","busiName":"鍘嬫祴瀹℃壒琛ㄥ崟涓氬姟","modelType":"2","activityManage":"[]","dataManage":"[]","formId":"ef415608-9f87-4e37-9e54-5a27661a8ec2","proModelId":"5e8052dd-1e15-4214-a76d-67b343462045","isDraft":"0","instanceNum":3,"version":null,"deploymentId":"2283663","status":1,"createBy":"zhangmiao@hq.cmcc","createTime":"2020-12-15 10:01:47","updateBy":"zhangmiao@hq.cmcc","updateTime"
            "":"2020-12-15 10:15:00","deleteFlag":null,"authorityType":null,"fromFrontDesign":1}", 
            LAST);
    
        web_url("getInfo_2", 
            "URL=http://10.10.10.10:7924/alpha/getInfo", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", 
            "Snapshot=t55.inf", 
            "Mode=HTML", 
            LAST);
    
        web_custom_request("subOrganization", 
            "URL=http://10.10.10.10:7924/alpha/common/get/subOrganization", 
            "Method=POST", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", 
            "Snapshot=t56.inf", 
            "Mode=HTML", 
            "EncType=application/json;charset=utf-8", 
            "Body={"deptId":"4500100001"}", 
            EXTRARES, 
            "Url=/smartCT/static/fonts/iconfont.8efbc988.eot", "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", ENDITEM, 
            LAST);
    
        web_custom_request("subOrganization_2", 
            "URL=http://10.10.10.10:7924/alpha/common/get/subOrganization", 
            "Method=POST", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", 
            "Snapshot=t57.inf", 
            "Mode=HTML", 
            "EncType=application/json;charset=utf-8", 
            "Body={"deptId":"4500100001"}", 
            LAST);
    
        lr_start_transaction("faqiShenpiBiaodan");
    
        web_reg_save_param("ResponseBody", "LB=", "RB=", "Search=Body", LAST);
        web_reg_save_param("bidaodan_startProcess_msg",
            "LB=msg":"",
            "RB=,"code":200",
            "Search=Body",
        LAST);
    
        web_add_header("Authorization","{NewCookie}");
    
        web_custom_request("startProcess", 
            "URL=http://10.10.10.10:7924/alpha/gather/task/startProcess", 
            "Method=POST", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", 
            "Snapshot=t58.inf", 
            "Mode=HTML", 
            "EncType=application/json;charset=utf-8", 
            "BodyBinary={"fileInfos":null,"draftId":null,"formValues":"{\"list\":[{\"type\":\"textarea\",\"icon\":\"icon-diy-com-textarea\",\"visable\":\"\",\"editable\":\"\",\"options\":{\"editable\":\"\",\"associated\":false,\"value\":\"test1215\",\"required\":false,\"disabled\":false,\"printOk\":false,\"pattern\":\"\",\"placeholder\":\"\xE8\xAF\xB7\xE8\xBE\x93\xE5\x85\xA5\",\"edit\":false,\""
            "remoteFunc\":\"func_1607997657000_52233\",\"visible\":true},\"name\":\"\xE5\xA4\x9A\xE8\xA1\x8C\xE8\xBE\x93\xE5\x85\xA5\xE6\xA1\x86\",\"key\":\"1607997657000_52233\",\"model\":\"textarea_1607997657000_52233\",\"rules\":[]},{\"type\":\"radio\",\"icon\":\"icon-radio\",\"visable\":\"\",\"editable\":\"\",\"options\":{\"inline\":false,\"value\":\"\xE9\x80\x89\xE9\xA1\xB9\xE4\xB8\x80\",\""
            "showLabel\":false,\"placeholder\":\"\xE8\xAF\xB7\xE9\x80\x89\xE6\x8B\xA9\",\"editable\":\"\",\"associated\":false,\"edit\":false,\"required\":false,\"width\":\"\",\"remote\":false,\"remoteOptions\":[],\"remoteFunc\":\"func_1607997658000_47413\",\"disabled\":false,\"printOk\":false,\"props\":{\"value\":\"value\",\"label\":\"label\"},\"options\":[{\"value\":\""
            "\xE9\x80\x89\xE9\xA1\xB9\xE4\xB8\x80\",\"associatedOption\":[]},{\"associatedOption\":[],\"value\":\"\xE9\x80\x89\xE9\xA1\xB9\xE4\xBA\x8C\"},{\"associatedOption\":[],\"value\":\"\xE9\x80\x89\xE9\xA1\xB9\xE4\xB8\x89\"}],\"visible\":true},\"name\":\"\xE5\x8D\x95\xE9\x80\x89\xE6\xA1\x86\",\"key\":\"1607997658000_47413\",\"model\":\"radio_1607997658000_47413\",\"rules\":[],\"val\":0},{\"type\":\"
            ""datetimerange\",\"icon\":\"icon-datetimerange\",\"visable\":\"\",\"editable\":\"\",\"options\":{\"editable\":\"\",\"width\":\"100%\",\"value\":\"\",\"required\":false,\"associated\":false,\"disabled\":false,\"type\":\"datetime\",\"printOk\":false,\"edit\":false,\"pattern\":\"\",\"placeholder\":\"\",\"format\":\"yyyy-MM-dd HH:mm:ss\",\"startPlaceholder\":\""
            "\xE8\xAF\xB7\xE9\x80\x89\xE6\x8B\xA9\",\"engPlaceholder\":\"\xE8\xAF\xB7\xE9\x80\x89\xE6\x8B\xA9\",\"startLabel\":\"\xE5\xBC\x80\xE5\xA7\x8B\xE6\x97\xB6\xE9\x97\xB4\",\"endLabel\":\"\xE7\xBB\x93\xE6\x9D\x9F\xE6\x97\xB6\xE9\x97\xB4\",\"duration\":false,\"startDate\":\"2020-12-29T16:00:00.000Z\",\"endDate\":\"2020-12-29T16:00:00.000Z\",\"timeLengthName\":\"\xE6\x97\xB6\xE9\x95\xBF\",\""
            "timeLength\":\"0\xE7\xA7\x92\",\"remoteFunc\":\"func_1607997660000_65807\",\"visible\":true},\"name\":\"\xE6\x97\xA5\xE6\x9C\x9F\xE5\x8C\xBA\xE9\x97\xB4\",\"key\":\"1607997660000_65807\",\"model\":\"datetimerange_1607997660000_65807\",\"rules\":[]},{\"type\":\"department\",\"icon\":\"icon-department\",\"visable\":\"\",\"editable\":\"\",\"options\":{\"editable\":\"\",\"inline\":false,\""
            "value\":\"\xE5\x85\xAC\xE5\x8F\xB8\xE9\xA2\x86\xE5\xAF\xBC\",\"associated\":false,\"showLabel\":false,\"required\":false,\"remote\":false,\"remoteOptions\":[],\"props\":{\"value\":\"value\",\"label\":\"label\"},\"remoteFunc\":\"func_1607997662000_67230\",\"edit\":false,\"disabled\":false,\"printOk\":false,\"placeholder\":\"\xE8\xAF\xB7\xE9\x80\x89\xE6\x8B\xA9\",\"type\":\"aDepartment\",\""
            "options\":[{\"value\":\"\xE5\x85\xAC\xE5\x8F\xB8\xE9\xA2\x86\xE5\xAF\xBC\",\"label\":1310120000},{\"value\":\"\xE7\xBB\xBC\xE5\x90\x88\xE4\xB8\x9A\xE5\x8A\xA1\xE9\x83\xA8\xEF\xBC\x88\xE6\xB3\x95\xE5\xBE\x8B\xE4\xBA\x8B\xE5\x8A\xA1\xE4\xB8\xAD\xE5\xBF\x83\xEF\xBC\x89\",\"label\":1310111443},{\"value\":\"\xE8\xB4\xA2\xE5\x8A\xA1\xE9\x83\xA8\",\"label\":1310110063},{\"value\":\""
            "\xE5\x85\x9A\xE5\xA7\x94\xE5\x8A\x9E\xE5\x85\xAC\xE5\xAE\xA4\xEF\xBC\x88\xE5\x85\x9A\xE7\xBE\xA4\xE5\xB7\xA5\xE4\xBD\x9C\xE9\x83\xA8|\xE5\x85\x9A\xE9\xA3\x8E\xE5\xBB\x89\xE6\x94\xBF\xE5\x8A\x9E\xE5\x85\xAC\xE5\xAE\xA4|\xE5\xB7\xA1\xE5\xAF\x9F\xE5\xB7\xA5\xE4\xBD\x9C\xE5\x8A\x9E\xE5\x85\xAC\xE5\xAE\xA4\xEF\xBC\x89\",\"label\":1310112337},{\"value\":\""
            "\xE7\xBA\xAA\xE5\xA7\x94\xE5\x8A\x9E\xE5\x85\xAC\xE5\xAE\xA4\",\"label\":1310111764},{\"value\":\"\xE5\x86\x85\xE5\xAE\xA1\xE9\x83\xA8\",\"label\":1310112395},{\"value\":\"\xE4\xBA\xBA\xE5\x8A\x9B\xE8\xB5\x84\xE6\xBA\x90\xE9\x83\xA8\",\"label\":1310110447},{\"value\":\"\xE8\xA7\x84\xE5\x88\x92\xE6\x8A\x80\xE6\x9C\xAF\xE9\x83\xA8\",\"label\":1310112339},{\"value\":\""
            "\xE8\xBF\x90\xE8\x90\xA5\xE7\xAE\xA1\xE7\x90\x86\xE9\x83\xA8\",\"label\":1310112336},{\"value\":\"\xE5\xB7\xA5\xE7\xA8\x8B\xE5\xBB\xBA\xE8\xAE\xBE\xE9\x83\xA8\",\"label\":1310112341},{\"value\":\"\xE5\xAE\x89\xE5\x85\xA8\xE7\xAE\xA1\xE7\x90\x86\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112383},{\"value\":\"\xE5\xA4\xA7\xE6\x95\xB0\xE6\x8D\xAE\xE5\xB9\xB3\xE5\x8F\xB0\xE9\x83\xA8\",\"label\""
            ":1310112382},{\"value\":\"\xE5\xA4\xA7\xE6\x95\xB0\xE6\x8D\xAE\xE5\xBA\x94\xE7\x94\xA8\xE9\x83\xA8\",\"label\":1310112381},{\"value\":\"\xE7\xAE\xA1\xE7\x90\x86\xE4\xBF\xA1\xE6\x81\xAF\xE7\xB3\xBB\xE7\xBB\x9F\xE9\x83\xA8\",\"label\":1310112340},{\"value\":\"\xE5\x9F\xBA\xE7\xA1\x80\xE5\xB9\xB3\xE5\x8F\xB0\xE9\x83\xA8\",\"label\":1310112338},{\"value\":\""
            "\xE9\x87\x87\xE8\xB4\xAD\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112385},{\"value\":\"\xE7\xA0\x94\xE5\x8F\x91\xE5\x88\x9B\xE6\x96\xB0\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112393},{\"value\":\"\xE6\x95\xB0\xE5\xAD\x97\xE5\x8C\x96\xE8\xBF\x90\xE8\x90\xA5\xE6\x94\xAF\xE6\x92\x91\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112386},{\"value\":\""
            "\xE6\x94\xBF\xE4\xBC\x81\xE4\xB8\x9A\xE5\x8A\xA1\xE6\x94\xAF\xE6\x92\x91\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112392},{\"value\":\"\xE5\x9B\xBD\xE9\x99\x85\xE4\xB8\x9A\xE5\x8A\xA1\xE8\xBF\x90\xE8\x90\xA5\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112388},{\"value\":\"\xE4\xBA\xA4\xE6\x98\x93\xE4\xB8\x9A\xE5\x8A\xA1\xE8\xBF\x90\xE8\x90\xA5\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112389},{\""
            "value\":\"\xE5\x8C\x97\xE4\xBA\xAC\xE4\xB8\x9A\xE5\x8A\xA1\xE6\x94\xAF\xE6\x92\x91\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112384},{\"value\":\"\xE6\xB7\xB1\xE5\x9C\xB3\xE4\xB8\x9A\xE5\x8A\xA1\xE6\x94\xAF\xE6\x92\x91\xE4\xB8\xAD\xE5\xBF\x83\",\"label\":1310112391},{\"value\":\"\xE5\xB9\xBF\xE5\xB7\x9E\xE4\xB8\x9A\xE5\x8A\xA1\xE6\x94\xAF\xE6\x92\x91\xE4\xB8\xAD\xE5\xBF\x83\",\"label\""
            ":1310112387}],\"visible\":true},\"name\":\"\xE9\x83\xA8\xE9\x97\xA8\",\"key\":\"1607997662000_67230\",\"model\":\"department_1607997662000_67230\",\"rules\":[]}]}","gicBusiSetting":{"busiId":198,"officeType":"1002","busiType":"2004","busiName":"\xE5\x8E\x8B\xE6\xB5\x8B\xE5\xAE\xA1\xE6\x89\xB9\xE8\xA1\xA8\xE5\x8D\x95\xE4\xB8\x9A\xE5\x8A\xA1","modelType":"2","activityManage":"[]","dataManage":"[]","formId":"
            ""ef415608-9f87-4e37-9e54-5a27661a8ec2","proModelId":"5e8052dd-1e15-4214-a76d-67b343462045","isDraft":"0","instanceNum":3,"version":null,"deploymentId":"2283663","status":1,"createBy":"zhangmiao@hq.cmcc","createTime":"2020-12-15 10:01:47","updateBy":"zhangmiao@hq.cmcc","updateTime":"2020-12-15 10:15:00","deleteFlag":null,"authorityType":null,"fromFrontDesign":1},"remark":"","busiId":198,"optionalNames":null}", 
            EXTRARES, 
            "Url=/smartCT/static/css/chunk-32e75233.c9de3287.css", "Referer=http://10.10.10.10:7924/smartCT/draftApprove/common", ENDITEM, 
            LAST);
    
        web_custom_request("myInitialProcess_2", 
            "URL=http://10.10.10.10:7924/alpha/gather/task/query/myInitialProcess", 
            "Method=POST", 
            "Resource=0", 
            "RecContentType=application/json", 
            "Referer=http://10.10.10.10:7924/smartCT/sponsor/index", 
            "Snapshot=t59.inf", 
            "Mode=HTML", 
            "EncType=application/json;charset=utf-8", 
            "Body={"officeType":null,"busiType":null,"status":null,"startTime":"","endTime":"","pageNum":1,"pageSize":10,"officeTypes":[],"busiTypes":[]}", 
            LAST);
    
        lr_output_message("响应报文体:
    %s",lr_eval_string("{ResponseBody}"));
    
        if (strcmp(lr_eval_string("{bidaodan_startProcess_msg}"),"璧疯崏浠诲姟鎴愬姛锛?")==0){
                lr_output_message("发起审批表单业务成功!");
                lr_end_transaction("faqiShenpiBiaodan",LR_PASS);
        }else{
            lr_error_message("发起审批报表单业务失败!");
            lr_end_transaction("faqiShenpiBiaodan",LR_FAIL);
        }
    
        //lr_end_transaction("faqiShenpiBiaodan",LR_AUTO);
    
        return 0;
    }
    View Code

    【Standard log】标准日志,脚本运行时发送函数信息,打印日志:

    【Extended log】扩展日志举例:

    5、【Parameter substitution】脚本运行时,在【Replay log】显示参数信息、参数值;

    6、【Data returned by server】记录服务器返回的所有数据;

    7、【Advanced trace】多用于脚本调试,记录VU在运行期间发送的所有函数信息。

  • 相关阅读:
    css3小叮当(转载)
    三大Flex布局用法(转载)
    移动前端:移动端页面坑与排坑技巧
    最好的前端开发资源推荐(转载)
    高效CSS开发核心要点摘录
    css常用代码大全以及css兼容(转载)
    如何处理CSS3属性前缀(转载)总结
    前端制作入门知识(转载)
    移动前端页面制作技巧(一)转载
    sass揭秘之@mixin,%,@function(转载)
  • 原文地址:https://www.cnblogs.com/apple2016/p/14142846.html
Copyright © 2020-2023  润新知