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 6943867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:12:43+00:00 2026-05-27T13:12:43+00:00

I am working on a project with python and I need to help about

  • 0

I am working on a project with python and I need to help about logging part. My logger have two handler(syslog and file log) and it send logs to both of them. Sometimes I need to send logs only one of them. How can I choose handler to be used? Thanks for help…

global my_Sysloghandler
global my_logger, my_log_handler

my_Sysloghandler=logging.handlers.SysLogHandler()
my_log_handler= logging.FileHandler('/var/log/{0}.log'.format(__project__))
my_log_handler.setFormatter(logging.Formatter('%(asctime)s %(message)s'))                                                                              
my_log_handler.setLevel(level)
my_logger= logging.getLogger('my_logger')
my_logger.addHandler(my_log_handler)
my_logger.addHandler(my_Sysloghandler)

my_logger.debug('This log is sent to both handler but I want to send it only my_logger')
  • 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-05-27T13:12:44+00:00Added an answer on May 27, 2026 at 1:12 pm

    I think your choices are:

    • Prioritize one over the other (i.e. SysLogHandler gets INFO messages or above, while FileHandler gets DEBUG or above)
    • Use two different logger instances.

    FWIW, the regular logging docs can be tough to read through. Instead, take a look at the Logging HOWTO and Logging Cookbook for something more easily digestible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have an at-home project now that I'm working on Python/Django at
I'm working with visual python on a project where I need to simulate a
I am working on a project in python in which I need to extract
For a project I'm working on I need to include some Python modules that
Just started working on a c project. Need help with passing function pointers/macro functions/etc.
Is there any Python project/module working on a binary plist writer? I need one
I am working on a project on python. I have divided my complete script
I have finished my first Django/Python Project and now I need to put the
I am currently working on two projects in python. One need python 2.5 and
I'm working on a project using Tkinter and Python. In order to have native

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.