0

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?

francadaval
  • 2,451
  • 3
  • 26
  • 36

4 Answers4

1

It's strongly not recommended to use Devstack for a production environment. it's unstable and only for developing purposes. So you can setup a native openedx instance then you can access the log files under /edx/var/logs/. but if you are sure about using Devstack, you may find log messages this way:

docker-compose logs --no-color --tail=1000 CONTAINER_NAME > logs.txt
mahyard
  • 1,230
  • 1
  • 13
  • 34
  • I don't want to use devstack for a production environment I just want the log files written under /edx/var/log as in a production environment. – francadaval Sep 03 '19 at 08:54
1

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

Isanka Wijerathne
  • 3,746
  • 3
  • 26
  • 34
0

@Mahyar Damavand , is there some way to write that logs to Elasticsearch?

Oksana B
  • 358
  • 1
  • 3
  • 17
0

Add this to the settings (lms/envs/devstack_docker.py)

LOGGING['handlers']['tracking'] = {
    'level': 'DEBUG',
    'class': 'logging.FileHandler',
    'filename': '/edx/var/log/tracking/tracking.log',
    'formatter': 'raw',
}

LOGGING['loggers']['tracking']['handlers'] = ['tracking']