Python Logging Handler

For the development, debugging and running of the system, logging is essential and when a program tends to crash and there is no record of logging, one would have no knowledge of what had occurred. Though logging is important, some may not know how to utilise them suitably.  You could use the standard python logging which is simple and easy.  For the python community, Logmatic.io has unified a python logging handler in order to make it easier for the user.  The python module comprises of a JSON formatter together with a socket handler which tends to feed python logs right to the service provider so that it is not essential for a log shipper, if one does not desire to use it.  Logging is a standard module which is well designed for easy use and is also flexible. The following would assist the user in configuring it into their system:

  1. Write the logs in JSON Format

It is easy and simple and all the relevant details are provided by the service provider

  1. Stream your logs to the Service Provider

Link your JSON Formatter to the Python Logging Handler from the provider by copy pasting from the instructions provided and the logs would be consumed right with the service provider.

  1. Addition of extra Details

You could explore and add details to the base formatter, based on what one would need for exploring for instance environments or hostnames.

In critical systems like in the case of elevators, planes or trains, there tends to be boxes logging all things continuously.  This is essential when the system tends to crash; someone would have the understanding of what could have transpired and work on the prevention of further occurrence. It is the same in the case of mobile or web apps wherein if its concerns at least a single user, you can be assured that in the event of a failure, someone would take control in comprehending the reason of its occurrence and how to resolve the same.  Hence logging matters for apps and also for critical systems.Some of the good practices of Python logging are listed below:

  1. Utilise the standard Python logging module

Python logging module has been created where all could rely on the same standard. The logging module enables the user to regulate the rigorous level one would desire to produce based on the output appenders and organization like – dev, production, staging etc. The logger events also seem to be created as time and place specific where the occasions tend to come as date, logger name, module name, line number etc.  This information tends to be valuable in order to influence the log events produced.

  1. Log wherever you can

Having a good library where one can depend on, the purpose is to be in a position of utilising it as much as one could possibly can.  This means that your code needs to offer adequate details at the severity stage.  We frequently consider about warn, severe and exception stage since these tend to be usual suspect warning where some occurrence could go erroneous.  You could do a rout-cause evaluation or locate probes services where one should log at info and debug levels