GeoNode / geonode-project

A django template project for creating custom GeoNode projects.
http://geonode.org
80 stars 174 forks source link

LDAP contrib app output is not logged #156

Closed gannebamm closed 4 years ago

gannebamm commented 4 years ago

If LDAP_ENABLED = True you would expect it to print logging information. But since it is not part of the LOGGING setup it wont display any. Therefore it should be added to https://github.com/GeoNode/geonode-project/blob/master/project_name/settings.py#L124

gannebamm commented 4 years ago

Since we do not know if the contrib app is used, we have to update the LOGGING information if LDAP_ENABLED = True like:

LOGGING.update(
"loggers": {
        "django": {
            "handlers": ["console"], "level": "ERROR", },
        "geonode": {
            "handlers": ["console"], "level": "INFO", },
        "geoserver-restconfig.catalog": {
            "handlers": ["console"], "level": "ERROR", },
        "owslib": {
            "handlers": ["console"], "level": "ERROR", },
        "pycsw": {
            "handlers": ["console"], "level": "ERROR", },
        "celery": {
            "handlers": ["console"], "level": "DEBUG", },
        "mapstore2_adapter.plugins.serializers": {
            "handlers": ["console"], "level": "DEBUG", },
        "geonode_logstash.logstash": {
            "handlers": ["console"], "level": "DEBUG", },
    # add ldap logger 
        "django_auth_ldap": {
            'handlers': ["console"], 'level': 'DEBUG', },
    },
)

@t-book @afabiani Are you with me?

EDIT: This is not nice and not DRY. Isn´t there a better way to achieve this?

t-book commented 4 years ago

@gannebamm In general I do agree

EDIT: This is not nice and not DRY. Isn´t there a better way to achieve this?

Untested but maybe something like this could work.

if LDAP_ENABLED and 'geonode_ldap' not in INSTALLED_APPS:
    import logging
    logger = logging.getLogger('django_auth_ldap')
    logger.addHandler(logging.StreamHandler())
    logger.setLevel(logging.DEBUG)
gannebamm commented 4 years ago

Closed by https://github.com/GeoNode/documentation/pull/65