Where can I find locust logs?

Beenz picture Beenz · Sep 26, 2014 · Viewed 8.6k times · Source

I'm using locust to stress test our app.

I'm getting errors because the POST call seems incorrect. Where can I see the logs for locust? I'd like to see what the post call looks like to see what's wrong.

Here's my code in case someone can tell me what I'm doing wrong:

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

Thanks!

Answer

Brian picture Brian · Aug 9, 2016

By adding --logfile=locustfile.log parameter when starting locust, your print messages will be redirected to a file called locustfile.log, which I think is the log you mentioned in your question.

Suppose your locust file name is locustfile.py. And you run locust on your local machine. You can start locust by locust --host=http://127.0.0.1 --logfile=locustfile.log. Then you'll be able to run locust test on http://127.0.0.1:8089/.