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;








0















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!










share|improve this question




























    0















    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!










    share|improve this question
























      0












      0








      0








      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!










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 17:01









      BenBen

      1,38611017




      1,38611017






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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






          share|improve this answer

























          • Hi @Ben this works for you ?

            – Kevin Martins
            Apr 24 at 18:09











          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
          );



          );













          draft saved

          draft discarded


















          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









          0














          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






          share|improve this answer

























          • Hi @Ben this works for you ?

            – Kevin Martins
            Apr 24 at 18:09















          0














          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






          share|improve this answer

























          • Hi @Ben this works for you ?

            – Kevin Martins
            Apr 24 at 18:09













          0












          0








          0







          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






          share|improve this answer















          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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          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

















          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript