Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to Print Failure to Console? #711

Closed
rendybjunior opened this issue Dec 18, 2017 · 3 comments
Closed

Option to Print Failure to Console? #711

rendybjunior opened this issue Dec 18, 2017 · 3 comments

Comments

@rendybjunior
Copy link

Issue Description - Option to Print failure to console

I'm currently doing performance test, and finding it hard to trace the failure from failure message received on client side. I'm using headless server, so there's no way to trace it like a web UI do.

Expected Behaviour

Logging failure to file whenever get non 200 response code

Actual behavior

I also checked the code, and find out that print_error_log only called when locust is shutting down, and it will print all the errors. Will be nice if we could get the failure logged to file.

@cgoldberg
Copy link
Member

use the --logfile option when starting Locust.

@rendybjunior
Copy link
Author

I have tried to use logfile, but it still dont appear, do I have to set log level somewhere? Thank you.

@heyman
Copy link
Member

heyman commented Dec 20, 2017

You could achieve this by hooking into the request_failure event. Add this to your lcoustfile:

from locust.events import request_failure

def on_request_failure(request_type, name, response_time, exception, **kwargs):
    print("%s %s failed: %s" % (request_type, name, exception))

request_failure += on_request_failure

I'm not sure this is a common enough use-case to warrant it as an extra built-in locust feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants