src/example.py
def my_logging_setup(log_name='example.log', use_async=False):
    """
    An example of setting up logging in Python using a JSON dictionary to configure it.
    You can also use an outside .conf text file; see ConcurrentLogHandler/README.md

    If you want to use async logging, call this after your main logging setup as shown below:

    concurrent_log_handler.queue.setup_logging_queues()
    """

    # Import this to install logging.handlers.ConcurrentRotatingFileHandler
    # The noinspection thing is so PyCharm doesn't think we're using this for no reason
    # noinspection PyUnresolvedReferences
    import concurrent_log_handler

    logging_config = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'default': {
                'format': '%(asctime)s %(levelname)s %(name)s %(message)s'
            },
            'example2': {
                'format': '[%(asctime)s][%(levelname)s][%(filename)s:%(lineno)s]'
                          '[%(process)d][%(message)s]',
            }
        },

        # Set up our concurrent logger handler. Need one of these per unique file.
        'handlers': {
            'my_concurrent_log': {
                'level': 'DEBUG',
                'class': 'logging.handlers.ConcurrentRotatingFileHandler',

                # Example of a custom format for this log.
                'formatter': 'example2',
                # 'formatter': 'default',

                'filename': log_name,

                # Optional: set an owner and group for the log file
                # 'owner': ['greenfrog', 'admin'],

                # Sets permissions to owner and group read+write
                'chmod': 0o0660,

                # Note: this is abnormally small to make it easier to demonstrate rollover.
                # A more reasonable value might be 10 MiB or 10485760
                'maxBytes': 240,

                # Number of rollover files to keep
                'backupCount': 10,

                # 'use_gzip': True,
            }
        },

        # Tell root logger to use our concurrent handler
        'root': {
            'handlers': ['my_concurrent_log'],
            'level': 'DEBUG',
        },
    }

    logging.config.dictConfig(logging_config)

    if use_async:
        # To enable background logging queue, call this near the end of your logging setup.
        from concurrent_log_handler.queue import setup_logging_queues
        setup_logging_queues()

    return

    An example of setting up logging in Python using a JSON dictionary to configure it.
    You can also use an outside .conf text file; see ConcurrentLogHandler/README.md

    If you want to use async logging, call this after your main logging setup as shown below:

    concurrent_log_handler.queue.setup_logging_queues()
    
An example of setting up logging in Python using a JSON dictionary to configure it.
You can also use an outside .conf text file; see ConcurrentLogHandler/README.md

If you want to use async logging, call this after your main logging setup as shown below.


An example of setting up logging in Python using a JSON dictionary to configure it . You can also use an outside . conf text file ; see ConcurrentLogHandler / README . md If you want to use async logging call this after your main logging setup as shown below .
def my_logging_setup(log_name='example.log', use_async=False):
    import concurrent_log_handler
    logging_config = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'default': {
                'format': '%(asctime)s %(levelname)s %(name)s %(message)s'
            },
            'example2': {
                'format': '[%(asctime)s][%(levelname)s][%(filename)s:%(lineno)s]'
                          '[%(process)d][%(message)s]',
            }
        },
        'handlers': {
            'my_concurrent_log': {
                'level': 'DEBUG',
                'class': 'logging.handlers.ConcurrentRotatingFileHandler',
                'formatter': 'example2',
                'filename': log_name,
                'chmod': 0o0660,
                'maxBytes': 240,
                'backupCount': 10,
            }
        },
        'root': {
            'handlers': ['my_concurrent_log'],
            'level': 'DEBUG',
        },
    }
    logging.config.dictConfig(logging_config)
    if use_async:
        from concurrent_log_handler.queue import setup_logging_queues
        setup_logging_queues()
    return
def my_logging_setup ( log_name = 'example.log' , use_async = False ) : import concurrent_log_handler logging_config = { 'version' : 1 , 'disable_existing_loggers' : False , 'formatters' : { 'default' : { 'format' : '%(asctime)s %(levelname)s %(name)s %(message)s' } , 'example2' : { 'format' : '[%(asctime)s][%(levelname)s][%(filename)s:%(lineno)s]' '[%(process)d][%(message)s]' , } } , 'handlers' : { 'my_concurrent_log' : { 'level' : 'DEBUG' , 'class' : 'logging.handlers.ConcurrentRotatingFileHandler' , 'formatter' : 'example2' , 'filename' : log_name , 'chmod' : 0o0660 , 'maxBytes' : 240 , 'backupCount' : 10 , } } , 'root' : { 'handlers' : [ 'my_concurrent_log' ] , 'level' : 'DEBUG' , } , } logging . config . dictConfig ( logging_config ) if use_async : from concurrent_log_handler . queue import setup_logging_queues setup_logging_queues ( ) return
An example of setting up logging in Python using a JSON dictionary to configure it.
An example of setting up logging in Python using a JSON dictionary to configure it .
"""
    An example of setting up logging in Python using a JSON dictionary to configure it.
    You can also use an outside .conf text file; see ConcurrentLogHandler/README.md

    If you want to use async logging, call this after your main logging setup as shown below:

    concurrent_log_handler.queue.setup_logging_queues()
    """ # Import this to install logging.handlers.ConcurrentRotatingFileHandler # The noinspection thing is so PyCharm doesn't think we're using this for no reason # noinspection PyUnresolvedReferences # Set up our concurrent logger handler. Need one of these per unique file. # Example of a custom format for this log. # 'formatter': 'default', # Optional: set an owner and group for the log file # 'owner': ['greenfrog', 'admin'], # Sets permissions to owner and group read+write # Note: this is abnormally small to make it easier to demonstrate rollover. # A more reasonable value might be 10 MiB or 10485760 # Number of rollover files to keep # 'use_gzip': True, # Tell root logger to use our concurrent handler # To enable background logging queue, call this near the end of your logging setup.
log_name
use_async