Logging before or after a function?

Viewed 787

We are trying to get some knowledge how production environments are working with their logs.

Are they logging before any significant function:

logger.info("Deleting virtual machine. VMName: {}".format(vm.name))
vm.delete()

Or they are logging after any significant function:

vm.delete()
logger.info("Successfully deleted virtual machine. VMName: {}".format(vm.name))

Or they are using both but with 'debug' and 'info', as this person advised (https://stackoverflow.com/a/4577523/6468443):

logger.debug("Deleting virtual machine. VMName: {}".format(vm.name))
vm.delete()
logger.info("Successfully deleted virtual machine. VMName: {}".format(vm.name))

Does anyone have experience with logs, and I'll just highligt that the will is to know how to do it right and operationally.

1 Answers
Related