12 Logging and exception handling

This chapter covers

  • Logging to files
  • Formatting logs properly
  • Handling exceptions
  • Raising exceptions

When we move our application into production, we temporarily “lose” control of our product; we must rely on the product itself to behave. If we’ve been extremely careful during the development phase, we may be lucky enough to have a perfect product that has no bugs. This almost never happens, however. Thus, we should know that a variety of problems, such as an unusual amount of traffic to our web app, can occur. Should any problem arise, we don’t panic; we start the problem-solving process.

Sometimes, we don’t have the chance to talk to the users who report the problem, and even if we do, the information they ...

Get Python How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.