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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:10:35+00:00 2026-06-10T06:10:35+00:00

i have multiple spiders in one project , problem is right now i am

  • 0

i have multiple spiders in one project , problem is right now i am defining LOG_FILE in SETTINGS like

LOG_FILE = "scrapy_%s.log" % datetime.now()

what i want is scrapy_SPIDERNAME_DATETIME

but i am unable to provide spidername in log_file name ..

i found

scrapy.log.start(logfile=None, loglevel=None, logstdout=None)

and called it in each spider init method but its not working ..

any help would be appreciated

  • 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-10T06:10:37+00:00Added an answer on June 10, 2026 at 6:10 am

    The spider’s __init__() is not early enough to call log.start() by itself since the log observer is already started at this point; therefore, you need to reinitialize the logging state to trick Scrapy into (re)starting it.

    In your spider class file:

    from datetime import datetime
    from scrapy import log
    from scrapy.spider import BaseSpider
    
    class ExampleSpider(BaseSpider):
        name = "example"
        allowed_domains = ["example.com"]
        start_urls = ["http://www.example.com/"]
    
        def __init__(self, name=None, **kwargs):
            LOG_FILE = "scrapy_%s_%s.log" % (self.name, datetime.now())
            # remove the current log
            # log.log.removeObserver(log.log.theLogPublisher.observers[0])
            # re-create the default Twisted observer which Scrapy checks
            log.log.defaultObserver = log.log.DefaultObserver()
            # start the default observer so it can be stopped
            log.log.defaultObserver.start()
            # trick Scrapy into thinking logging has not started
            log.started = False
            # start the new log file observer
            log.start(LOG_FILE)
            # continue with the normal spider init
            super(ExampleSpider, self).__init__(name, **kwargs)
    
        def parse(self, response):
            ...
    

    And the output file might look like:

    scrapy_example_2012-08-25 12:34:48.823896.log

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

Sidebar

Related Questions

So, my problem is relatively simple. I have one spider crawling multiple sites, and
I have multiple UpdatePanels on a webpage, one inside UserControl (Purple ColorBox as show
I would like to insert multible sliders in one page. I have a block
I have multiple forms like so: <form method=post action=change.php id=form1> <input name=product_id type=hidden value=abc
I have a need to store multiple datatypes(like int or string mostly) inside a
I have multiple lines of text in log files in this kind of format:
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
I have multiple projects in a couple of different workspaces. However, it seems like
I have multiple classes that all derive from a base class, now some of
I had multiple spiders in my project folder and want to run all the

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.