我在哪里可以找到蝗虫日志?

Bee*_*enz 5 logging locust

我正在使用蝗虫来压力测试我们的应用程序.

我收到错误,因为POST调用似乎不正确.我在哪里可以看到蝗虫的日志?我想看看帖子看起来是什么样的,看看有什么不对.

这是我的代码,万一有人可以告诉我我做错了什么:

from locust import HttpLocust, TaskSet, task

json3 = """{"stack_name": "beenz-php-app-12", "disable_rollback": true, "template": "php", "timeout_mins": 60}"""

class MyTaskSet(TaskSet):
    @task
    def send(self):
             response = self.client.post("/stacks", json3, headers={'X-Auth-Key': 'xxxx', 'Content-Type': 'application/json', 'X-Auth-User': 'xxxx', 'Accept': 'application/json', 'X-Auth-Token':'xxxx'})
            print "Response status code:", response.status_code
            print "Response content:", response.content

class MyLocust(HttpLocust):
    task_set = MyTaskSet
    min_wait = 5000
    max_wait = 15000
Run Code Online (Sandbox Code Playgroud)

谢谢!

Bri*_*ian 8

通过--logfile=locustfile.log在启动蝗虫时添加参数,您的print消息将被重定向到一个名为的文件locustfile.log,我认为这是您在问题中提到的日志.

假设您的locust文件名是locustfile.py.你在本地机器上运行蝗虫.你可以开始蝗虫locust --host=http://127.0.0.1 --logfile=locustfile.log.然后你就可以运行蝗虫测试了http://127.0.0.1:8089/.


hey*_*man 0

以 开头的行有语法错误response = self.client.post(...。最后一个字符串永远不会闭合:'X-Auth-Token':'xxxx}

将其更改为'X-Auth-Token':'xxxx'},脚本应该可以正常工作。

当使用您发布的脚本(带有语法错误)启动 Locust 时,您将立即收到异常和堆栈跟踪。