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

Catching erros from app #105

Closed
ambrous opened this issue May 31, 2018 · 5 comments
Closed

Catching erros from app #105

ambrous opened this issue May 31, 2018 · 5 comments

Comments

@ambrous
Copy link

ambrous commented May 31, 2018

Hi!

I am using OpenTAXII of version of 0.1.9 with gunicorn web server.

When an error occurs in my custom api or data converters the error it written to usual log file with other information which I write myself. So I can't set up my monitoring system to detect only error, but not all info from log.

I have following gunicorn start command:

gunicorn opentaxii.http:app --bind localhost:7070
--timeout 300
--max-requests 100
--max-requests-jitter 20
--access-logfile /var/log/access-taxii.log
--error-logfile /var/log/error-taxii.log
--log-level info

As I understand all errors are catched by middleware by handle_internal_error function to respond xml then, so how can I forward this catched error to error log file as well?

I tried to use default gunicorn config (http://www.opentaxii.org/en/stable/running.html), but had the same case.

Thanks in advance!

@traut
Copy link
Contributor

traut commented May 31, 2018

@ambrous Maybe I misunderstood the issue, but catching all logs or just errors should not be a problem. OpenTAXII writes logs in json-lines format, where every log-line is a json message. The logging level you can control with logging property in your custom settings file (default configuration). Another way is to catch all logging output in info or debug level and filter it out in your monitoring system.

@ambrous
Copy link
Author

ambrous commented May 31, 2018

@traut thanks a lot for your answer!

Yes, I tried to change logging level in loggin section in our server config, but with any level all logs are written into stdout, including errors as log-line json string (as you mentioned). However I need writing error into stderr.

As I understand, by logging level we can manage what kind of logs we want to see in our log, but can't write error to other log file or stream. Right?

@traut
Copy link
Contributor

traut commented May 31, 2018

However I need writing error into stderr.

ah, now I see what you mean!

As I understand, by logging level we can manage what kind of logs we want to see in our log, but can't write error to other log file or stream. Right?

correct. You would have to write/use your own stream handler. This is not something OpenTAXII supports out of the box. I feel you can catch / redirect error messages from stdout that gunicorn produces relatively easy though. Maybe with jq and some bash magic?

@ambrous
Copy link
Author

ambrous commented May 31, 2018

@traut Thanks for your help!

I have had some experiments with gunicorn config, but with unsuccssed result, Then I found that gunicorn error log ONLY for error within gunicorn server (it was discussed here benoitc/gunicorn#1124).

I just thought that this might be supported out of the box. So it seem to me that I really have to find other way.

So the issue must be closed.

@traut
Copy link
Contributor

traut commented May 31, 2018

@ambrous good luck!

@traut traut closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants