Skip to main content

log for python like log4j2

Project description



log for python like java log4j2

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

Important Update

  • support python 3.7

  • remove flume-log

  • fix some bugs

  • improve config file document


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

out put like this:
2015-01-20 16:18:47,692 DEBUG [Thread-3] data.LogInsert ( - Debug Log
2015-01-20 16:18:47,692 DEBUG [Thread-3] data.LogInsert ( - 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.3.tar.gz (8.5 kB view hashes)

Uploaded source

Supported by

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