Search code examples
devstackopenedxedx

How can I write LMS logs to file in Open edX devstack?


Open edX uses to write logs files on /edx/var/log but in the LMS docker instance all folders in this path are empty and the only file I've found ('tracking.log`) is empty too.

I can see logs output with make lms-logs command on devstack but I want log files written on disk as it would be on a production environment.

I'm running hawthorn version and I've not done any change yet.

How can I enable this?


Solution

  • If I'm not wrong Open edX does devstack does not record log files in /edx/var/log support. And rsylog is also not running on the containers.

    If you really want to do, there is a tricky way to enable it with custom changes in several places. Before that,

    As you know any changes in containers are not persistent. Once you restart the containers you have to start rsylog again

    First, start rsylog in lms container

    make lms-shell
    service rsyslog status
    service rsyslog start
    

    Then check the log listen socket is enabled in /dev folder inside the LMS container.

    ls /dev/log -l
    

    If you can see /dev/log, then you have to add a few changes to your edx-platform/lms/envs/devstack_docker.py file to enable logging.

    from openedx.core.lib.logsettings import get_logger_config
    
    
    
    LOCAL_LOGLEVEL = "INFO"
    SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)
    LOGGING_ENV = 'sandbox'
    LOG_DIR = "/edx/var/log/edx"
    
    LOGGING = get_logger_config(LOG_DIR,
                                logging_env=LOGGING_ENV,
                                local_loglevel=LOCAL_LOGLEVEL,
                                service_variant=SERVICE_VARIANT)
    

    Then create empty log files in the LMS container

    /edx/var/log/edx/lms/edx.org
    /edx/var/log/edx/cms/edx.org
    /edx/var/log/tracking/tracking.log
    

    Now you can check the logs, tail /edx/var/log/edx/lms/edx.org and you will see,

    enter image description here