Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8859363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:02:35+00:00 2026-06-14T15:02:35+00:00

I am trying to set up a Fluentd log handler from a Django project

  • 0

I am trying to set up a Fluentd log handler from a Django project using a logger from code:

def get_fluentd_logger(name):
    import logging
    from fluent import handler

    logging.basicConfig(level=logging.DEBUG)
    logger = logging.getLogger(name)
    logger.addHandler(handler.FluentHandler(name, host='localhost', port=24224))
    return logger

handler.FluentHandler comes from package fluent-logger and I am running fluent locally.

fluent.conf:

<source>
  type forward
  port 24224
</source>

<match **>
  type copy
  <store>
        type stdout
  </store>

  <store>
          type forward
          send_timeout 60s
          recover_wait 10s
          heartbeat_interval 1s
          phi_threshold 8
          hard_timeout 60s

          <server>
            name monitoring
            host 1.2.3.4
            port 24224
            weight 100
          </server>
  </store>
</match>

When I run this from a non-django python project it works fine, but when called from django it just does not do anything.

The question is: is there a way to see the currently installed loggers and their handlers so I can debug this situation?

[EDIT]

When done from the django settings like this:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '%(levelname)s: %(message)s'
        },
    },
    'handlers': {
       'fluentdebug':{
            'level':'DEBUG',
            'class':'fluent.handler.FluentHandler',
            'formatter': 'simple',
            'tag':'foo.bar.baz',
            'host':'localhost',
            'port':24224,
        },
    },
    'loggers': {
        'foo.bar.baz': {
            'handlers': ['fluentdebug'],
            'level': 'DEBUG',
            'propagate': True,
        },
    }
}

It does work. I however would like to be able to do this from code because foo.bar.baz can take many values and I dont want to pollute this file with 20 loggers and handlers that do exactly the same.

Maybe the real question is: Why cant I add loggers from code to logging after Django has performed it’s setup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:02:36+00:00Added an answer on June 14, 2026 at 3:02 pm

    I am going to answer myself because if somebody runs in the same problem it is easier to find.
    The problem seems to be with the FluentHandler. Using Brandon’s Logging tree as mentioned by @Thomas we could see that the loggers were correctly added.

    However further debugging showed that if you not explicitly set the loglevel it is set to NotSet. Somehow in “ordinary” python this is ok and the record is emitted. In Django however NotSet level logs are thrown away. I don’t know if this is standard Django behaviour, but it caused a lot of headaces. Below is the code that worked:

    def get_fluentd_logger(name):
        import logging
        from fluent import handler
    
        logging.basicConfig(level=logging.DEBUG)
        logger = logging.getLogger(name)
        logger.level = logging.INFO
        handler = handler.FluentHandler(name, host='localhost', port=24224)
        handler.level = logging.INFO
        logger.addHandler(handler)
        return logger
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to set up a new project, and running into a weird issue. I
Im trying to set the certificate friendly name during the certificate request/acceptance process. I
I am trying to set up proper domain architecture using Fluent NHibernate and Linq
I am trying to implement Bidirectional Mapping with Fluent NHibernate Mapping. Code snippet from
I'm trying to setup a simple inheritance scenario with EF 4.3.1 using code first
I'm trying to map an existing database using Entity Framework Code First Fluent API.
Im trying set the single table inheritance model type in a form. So i
Trying to set up a self signed certificate, for our intranet's web services site.
Trying to set it so if a certain condition is met then one of
Trying to set up a dependency in C++ with a parent-child relationship. The parent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.