Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not adding INFO logs to the logstash when used with Django. #113

Open
durgeksh opened this issue Aug 8, 2024 · 0 comments
Open

Not adding INFO logs to the logstash when used with Django. #113

durgeksh opened this issue Aug 8, 2024 · 0 comments

Comments

@durgeksh
Copy link

durgeksh commented Aug 8, 2024

Hi team,
I am using logstash with loguru 0.7.2. Django version is 5.0.8. My config is as below. Whenever I get any WARNING, it is added to the logstash but if I print INFO log, it is not added to logstash.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,

    'handlers': {
        'logstash': {
            'level': 'DEBUG',
            'class': 'logstash.TCPLogstashHandler',
            'host': 'localhost',
            'port': 5959,  # Default value: 5959
            'version': 1,
            # Version of logstash event schema. Default value: 0 (for backward compatibility of the library)
            'message_type': 'logstash',  # 'type' field in logstash message. Default value: 'logstash'.
            'fqdn': False,  # Fully qualified domain name. Default value: false.
            'tags': ['tag1', 'tag2'],  # list of tags. Default: None.
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['logstash'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

logstash.conf file

input {
  tcp {
    port => 5959
    codec => json
  }
}

filter {
  date {
    match => ["timestamp", "YYYY-MM-dd HH:mm:ss,SSS"]
    timezone => "UTC"
  }
}

output {
  elasticsearch {
    hosts => ["elasticsearch:9200"]
    index => "django-logs"
  }
  stdout { codec => rubydebug }
}

docker-compose.yml file

services: 
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.14.3
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - ./esdata:/usr/share/elasticsearch/data
    restart: always

  logstash:
    image: docker.elastic.co/logstash/logstash:8.14.3
    container_name: logstash
    volumes:
      - ./logstash:/usr/share/logstash/pipeline
    ports:
      - "5959:5959"
      - "9600:9600"
    depends_on:
      - elasticsearch
    restart: always

  kibana:
    image: docker.elastic.co/kibana/kibana:8.14.3
    container_name: kibana
    environment:
      - ELASTICSEARCH_URL=http://elasticsearch:9200
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
    restart: always

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant