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

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현