Python logging into file as a dictionary or JSON
问题 I am trying to set up logging where I can log in both stdout and on to a file. This i have accomplished using the following code: logging.basicConfig( level=logging.DEBUG, format='%(asctime)-15s %(levelname)-8s %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', handlers=[logging.FileHandler(path), logging.StreamHandler()]) The output of this something like this: 2018-05-02 18:43:33,295 DEBUG Starting new HTTPS connection (1): google.com 2018-05-02 18:43:33,385 DEBUG https://google.com:443 "GET /