Code Monkey home page Code Monkey logo

Comments (4)

eht16 avatar eht16 commented on June 30, 2024

Just tested and it works for me.
Can you post the relevant part of your config?

Or compare your config to the following snippet which should work:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'logstash': {
            '()': 'logstash_async.formatter.DjangoLogstashFormatter',
            'message_type': 'customer-message-type',
            'fqdn': False, # Fully qualified domain name. Default value: false.
            'extra_prefix': 'py',
            'extra': [...]
        }
    }
[...]

from python-logstash-async.

 avatar commented on June 30, 2024

I did a compare with you config snippet and using the GitHub config, but doesn't work either :-(

My config is:

    'loggers': {
        'django.request': {
            'level': 'INFO', 
            'propagate': True, 
            'handlers': ['logstash']
        }, 

[...]

    'disable_existing_loggers': False, 
    'version': 1, 
    'formatters': {
        'verbose': {
            'datefmt': '%Y-%m-%d %H:%M:%S', 
            'format': '[%(asctime)s] %(levelname)s %(message)s'
        }, 
        'logstash': {
            '()': 'logstash_async.formatter.DjangoLogstashFormatter', 
            'message_type': 'logstash-test'
        }
    }, 

[...]
'handlers': {
        'logstash': {
            'host': 'X.X.X.X', 
            'certfile': 'logstash.crt', 
            'ssl_enable': True, 
            'ssl_verify': False, 
            'database_path': 'logstash.db', 
            'keyfile': 'logstash.key', 
            'class': 'logstash_async.handler.AsynchronousLogstashHandler', 
            'transport': 'logstash_async.transport.TcpTransport', 
            'port': 5959
        }, 
[...]

    'root': {
        'handlers': ['console', 'logstash'], 
        'level': 'INFO'
    }


With this config I can see all the messages in Kibana, only the message_type (type field) was not being set.

from python-logstash-async.

 avatar commented on June 30, 2024

I figure out what I'm doing wrong (or not documented :-D ) ...

In the handler I need to set:

'formatter': 'logstash'

After that, its working :-)

Thank you so much!

from python-logstash-async.

eht16 avatar eht16 commented on June 30, 2024

Glad to hear it works now.
JFTR, the formatter option on handlers is not special to python-logstash-async, it's part of the logging framework. Anyway, I'll add the formatter option to the example in the docs in the next days.

from python-logstash-async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.