How do I log swagger / connexion request body?Access Flask methods like before_request when using ConnexionPython Connexion: Automatically validate Accept headermulti thread python connexion app using rabitmqHow to pass a variable into Connexion Flask app context?Swagger-ui connexion not finding Python nested functionsHow to include a .log suffix in the log file nameIn swagger file configuration it's possibile to get 2 parameters in pathPython logging — «catch-all» loggerHow to change error format of all errors using Connexion + TornadoChanging log level for child modules, given parent
Using `printf` to print variable containing `%` percent sign results in "bash: printf: `p': invalid format character"
Why does Taylor’s series “work”?
Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?
Why wear sunglasses in indoor velodromes?
Told to apply for UK visa before other visas
Lock out of Oracle based on Windows username
Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?
FIFO data structure in pure C
When did Britain learn about the American Declaration of Independence?
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Have GoT's showrunners reacted to the poor reception of the final season?
Bookshelves: the intruder
Why are stats in Angband written as 18/** instead of 19, 20...?
How come Arya Stark wasn't hurt by this in Game of Thrones Season 8 Episode 5?
How to get all possible paths in 0/1 matrix better way?
I recently started my machine learning PhD and I have absolutely no idea what I'm doing
Why is Drogon so much better in battle than Rhaegal and Viserion?
Why use a retrograde orbit?
How do we explain the use of a software on a math paper?
Appropriate liquid/solvent for life in my underground environment on Venus
Windows reverting changes made by Linux to FAT32 partion
Gaussian kernel density estimation with data from file
Why using a variable as index of a list-item does not retrieve that item with clist_item:Nn?
Have the writers and actors of GOT responded to its poor reception?
How do I log swagger / connexion request body?
Access Flask methods like before_request when using ConnexionPython Connexion: Automatically validate Accept headermulti thread python connexion app using rabitmqHow to pass a variable into Connexion Flask app context?Swagger-ui connexion not finding Python nested functionsHow to include a .log suffix in the log file nameIn swagger file configuration it's possibile to get 2 parameters in pathPython logging — «catch-all» loggerHow to change error format of all errors using Connexion + TornadoChanging log level for child modules, given parent
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm using connexion and Swagger to create an API in Python. I'd like to log all of the incoming calls to a file so I can see what's being requested. I've been able to log the path of the calls I've received but I can't figure out how to log the body.
Here's where I've configured my logging:
if __name__ == '__main__':
import logging
logging.basicConfig(format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s', filename='golden_record.log',level=logging.DEBUG)
When I look into the log, I see the path, as in the following for a POST call...
2019-03-23 12:47:16,182 - werkzeug - INFO - 127.0.0.1 - - [23/Mar/2019
12:47:16] "POST /golden_record/account HTTP/1.1" 400 -
but I don't see the body of the call (i.e. the data I've sent). Is there a way to automatically record this for every call that comes in? Doing so would help debug calls that aren't functioning as desired. Thanks!
python-logging connexion
add a comment |
I'm using connexion and Swagger to create an API in Python. I'd like to log all of the incoming calls to a file so I can see what's being requested. I've been able to log the path of the calls I've received but I can't figure out how to log the body.
Here's where I've configured my logging:
if __name__ == '__main__':
import logging
logging.basicConfig(format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s', filename='golden_record.log',level=logging.DEBUG)
When I look into the log, I see the path, as in the following for a POST call...
2019-03-23 12:47:16,182 - werkzeug - INFO - 127.0.0.1 - - [23/Mar/2019
12:47:16] "POST /golden_record/account HTTP/1.1" 400 -
but I don't see the body of the call (i.e. the data I've sent). Is there a way to automatically record this for every call that comes in? Doing so would help debug calls that aren't functioning as desired. Thanks!
python-logging connexion
add a comment |
I'm using connexion and Swagger to create an API in Python. I'd like to log all of the incoming calls to a file so I can see what's being requested. I've been able to log the path of the calls I've received but I can't figure out how to log the body.
Here's where I've configured my logging:
if __name__ == '__main__':
import logging
logging.basicConfig(format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s', filename='golden_record.log',level=logging.DEBUG)
When I look into the log, I see the path, as in the following for a POST call...
2019-03-23 12:47:16,182 - werkzeug - INFO - 127.0.0.1 - - [23/Mar/2019
12:47:16] "POST /golden_record/account HTTP/1.1" 400 -
but I don't see the body of the call (i.e. the data I've sent). Is there a way to automatically record this for every call that comes in? Doing so would help debug calls that aren't functioning as desired. Thanks!
python-logging connexion
I'm using connexion and Swagger to create an API in Python. I'd like to log all of the incoming calls to a file so I can see what's being requested. I've been able to log the path of the calls I've received but I can't figure out how to log the body.
Here's where I've configured my logging:
if __name__ == '__main__':
import logging
logging.basicConfig(format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s', filename='golden_record.log',level=logging.DEBUG)
When I look into the log, I see the path, as in the following for a POST call...
2019-03-23 12:47:16,182 - werkzeug - INFO - 127.0.0.1 - - [23/Mar/2019
12:47:16] "POST /golden_record/account HTTP/1.1" 400 -
but I don't see the body of the call (i.e. the data I've sent). Is there a way to automatically record this for every call that comes in? Doing so would help debug calls that aren't functioning as desired. Thanks!
python-logging connexion
python-logging connexion
asked Mar 23 at 17:01
BenBen
1,38611017
1,38611017
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Just add a Flask before_request.
Connexion instance stores the Flask instance as the app
attribute, so you can access using app.app
.
Add the code and you will log the body:
@app.app.before_request
def log_request_info():
print('Body: %s', request.get_data())
Change the print
method to your logger:
@app.app.before_request
def log_request_info():
logger.info('Body: %s', request.get_data())
The request
import is :
from flask import request
And the app
is your Connexion instance:
app = connexion.App(__name__, specification_dir="./swagger/")
I created a Gist with the code.
https://gist.github.com/kevinmmartins/f832c21215bb51cea73b8fdd28f6d88d
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316205%2fhow-do-i-log-swagger-connexion-request-body%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just add a Flask before_request.
Connexion instance stores the Flask instance as the app
attribute, so you can access using app.app
.
Add the code and you will log the body:
@app.app.before_request
def log_request_info():
print('Body: %s', request.get_data())
Change the print
method to your logger:
@app.app.before_request
def log_request_info():
logger.info('Body: %s', request.get_data())
The request
import is :
from flask import request
And the app
is your Connexion instance:
app = connexion.App(__name__, specification_dir="./swagger/")
I created a Gist with the code.
https://gist.github.com/kevinmmartins/f832c21215bb51cea73b8fdd28f6d88d
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
add a comment |
Just add a Flask before_request.
Connexion instance stores the Flask instance as the app
attribute, so you can access using app.app
.
Add the code and you will log the body:
@app.app.before_request
def log_request_info():
print('Body: %s', request.get_data())
Change the print
method to your logger:
@app.app.before_request
def log_request_info():
logger.info('Body: %s', request.get_data())
The request
import is :
from flask import request
And the app
is your Connexion instance:
app = connexion.App(__name__, specification_dir="./swagger/")
I created a Gist with the code.
https://gist.github.com/kevinmmartins/f832c21215bb51cea73b8fdd28f6d88d
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
add a comment |
Just add a Flask before_request.
Connexion instance stores the Flask instance as the app
attribute, so you can access using app.app
.
Add the code and you will log the body:
@app.app.before_request
def log_request_info():
print('Body: %s', request.get_data())
Change the print
method to your logger:
@app.app.before_request
def log_request_info():
logger.info('Body: %s', request.get_data())
The request
import is :
from flask import request
And the app
is your Connexion instance:
app = connexion.App(__name__, specification_dir="./swagger/")
I created a Gist with the code.
https://gist.github.com/kevinmmartins/f832c21215bb51cea73b8fdd28f6d88d
Just add a Flask before_request.
Connexion instance stores the Flask instance as the app
attribute, so you can access using app.app
.
Add the code and you will log the body:
@app.app.before_request
def log_request_info():
print('Body: %s', request.get_data())
Change the print
method to your logger:
@app.app.before_request
def log_request_info():
logger.info('Body: %s', request.get_data())
The request
import is :
from flask import request
And the app
is your Connexion instance:
app = connexion.App(__name__, specification_dir="./swagger/")
I created a Gist with the code.
https://gist.github.com/kevinmmartins/f832c21215bb51cea73b8fdd28f6d88d
edited Apr 7 at 21:52
answered Apr 7 at 21:45
Kevin MartinsKevin Martins
8818
8818
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
add a comment |
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
Hi @Ben this works for you ?
– Kevin Martins
Apr 24 at 18:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55316205%2fhow-do-i-log-swagger-connexion-request-body%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown