json-logging-python | native distributed Python logging library to emit JSON log

 by   bobbui Python Version: 1.5.0-rc0 License: Apache-2.0

kandi X-RAY | json-logging-python Summary

kandi X-RAY | json-logging-python Summary

json-logging-python is a Python library typically used in Logging applications. json-logging-python has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.

Python logging library to emit JSON log that can be easily indexed and searchable by logging infrastructure such as ELK , EFK , AWS Cloudwatch, GCP Stackdriver. If you're using Cloud Foundry, it might worth to check out the library SAP/cf-python-logging-support which I'm also original author.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              json-logging-python has a low active ecosystem.
              It has 274 star(s) with 55 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 13 open issues and 53 have been closed. On average issues are closed in 60 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of json-logging-python is 1.5.0-rc0

            kandi-Quality Quality

              json-logging-python has 0 bugs and 0 code smells.

            kandi-Security Security

              json-logging-python has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              json-logging-python code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              json-logging-python is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              json-logging-python releases are available to install and integrate.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              json-logging-python saves you 443 person hours of effort in developing the same functionality from scratch.
              It has 1700 lines of code, 229 functions and 33 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed json-logging-python and discovered the below as its top functions. This is intended to give you an instant insight into json-logging-python implemented functionality, and help decide if they suit your requirements.
            • Returns the correlation ID for the given request
            • Get the correlation id from the request header
            • Get the correlation id for the request
            • Get request from stack
            • Format log record
            • Return the fields of the exception
            • Sanitize log message
            • Format record
            • Get extra fields from a log record
            • Format a log record
            • Configure a Flask application
            • Check if Sanic is present
            • Configure the application
            • Check if the connection is present
            • Configure Flask application
            • Checks if flask is installed
            • Configure application logging
            • Check if Quart is present
            • Configure sanic
            • Get library logger
            • Dispatch the request
            • Register a framework support
            • Create a Flask application
            Get all kandi verified functions for this library.

            json-logging-python Key Features

            No Key Features are available at this moment for json-logging-python.

            json-logging-python Examples and Code Snippets

            No Code Snippets are available at this moment for json-logging-python.

            Community Discussions

            QUESTION

            How do I get my fastAPI application's console log in json format with a different structure and different fields?
            Asked 2022-Feb-22 at 12:51

            I have a fastAPI application where I would like to get the default logs written to the STDOUT with following data and in JSON format:

            App logs should look like this:

            ...

            ANSWER

            Answered 2022-Feb-22 at 12:51

            You could do that by creating a custom Formatter using the built-in logger module. You can use the extra parameter when logging messages to pass contextual information, such as url and headers. Python's JSON module already implements pretty-printing JSON data in the dump() function, using the indent parameter to define the indent level. Below is a working example using a custom formatter to log messages in the format you described in your question. For App logs use, for instance, logger.info('sample log message'), whereas, for Access logs, use logger.info('sample log message', extra={'extra_info': get_extra_info(request)}). By passing the request instance to the get_extra_info() method, you can extract information such as the one you mentioned above. For more LogRecord attributes, have a look here. The below example uses a FileHandler for logging the messages in a log file as well. If you don't need that, you can comment it out in the get_logger() method.

            app_logger.py

            Source https://stackoverflow.com/questions/70891687

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install json-logging-python

            You can download it from GitHub.
            You can use json-logging-python like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            To add support for a new web framework, you need to extend following classes in ** framework_base** and register support using ** json_logging.register_framework_support** method:. Take a look at json_logging/base_framework.py, ** json_logging.flask** and json_logging.sanic packages for reference implementations.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/bobbui/json-logging-python.git

          • CLI

            gh repo clone bobbui/json-logging-python

          • sshUrl

            git@github.com:bobbui/json-logging-python.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link