Skip to main content

log for python like log4j2

Project description

Introduction

log4python

log for python like java log4j2

use config file [log4p.py], in the application root directory.

Important Update

Content:
  • support python 3.7

  • remove flume-log

  • fix some bugs

  • improve config file document

Usage

from log4python.Log4python import log
TestLog = log("LogDemo")
TestLog.debug("Debug Log")
TestLog.info("Info Log")

out put like this:
2015-01-20 16:18:47,692 DEBUG [Thread-3] data.LogInsert (LogInsert.py:172) - Debug Log
2015-01-20 16:18:47,692 DEBUG [Thread-3] data.LogInsert (LogInsert.py:173) - Info Log

Config Example

config ={
    'monitorInterval' : 10,                         # auto reload time interval [secs]
    'loggers' :{
        'LogDemo' :{
            'level': "DEBUG",
            'additivity' : False,
            'AppenderRef' : ['LogDemo']
            },
        'root' :{
            'level' : "DEBUG",
            'AppenderRef' : ['output_root']
        }
    },
    'appenders' :{
        'output_root' :{
            'type' :"file",
            'FileName' :"root_error.log",            # log file name
            'backup_count': 5,                       # files count use backup log
            'file_size_limit': 1024 * 1024 * 20,     # single log file size, default :20MB
            'PatternLayout' :"[level:%(levelname)s-file:%(filename)s-lineno:%(lineno)d] %(asctime)s %(message)s"
        },
        'LogDemo' :{
            'type' :"file",
            'FileName' :"LogDemo.log",
            'PatternLayout' :"[level:%(levelname)s-file:%(filename)s-lineno:%(lineno)d] %(asctime)s %(message)s"
        },
        'console' :{
            'type' :"console",
            'target' :"console",
            'PatternLayout' :"[%(levelname)s] %(asctime)s %(message)s"
        }
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

log4python-1.0.5.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file log4python-1.0.5.tar.gz.

File metadata

  • Download URL: log4python-1.0.5.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/6.0.0 pkginfo/1.7.0 requests/2.28.2 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for log4python-1.0.5.tar.gz
Algorithm Hash digest
SHA256 bda59ff63ab0a7b74a67e18c0f1fa6bed4bb2370c9c5b9072c18f0abe3bc727e
MD5 168d1e93d11e48e2bc1a17af1d9d5f0c
BLAKE2b-256 046d9c35fa0bbee372e29fdb0e47eb69401c49b2f28d633c43b636a714778e74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page