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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:37:18+00:00 2026-06-11T10:37:18+00:00

I create the log file by this way: global logger logger = logging.getLogger(plus_dig_cname) logger.setLevel(logging.DEBUG)

  • 0

I create the log file by this way:

    global logger
    logger = logging.getLogger("plus_dig_cname")
    logger.setLevel(logging.DEBUG)

    fh = logging.FileHandler( fdoc_log + "/plus_dig_cname.log" )

    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fh.setFormatter(formatter)

    logger.addHandler(fh)

and when the size of plus_dig_cname.log is bigger than 300MB,I handle it by a shell script, the main process is:

 mv $LOG_DIR/$1 $LOG_DIR/$1.bk
 [ $? -ne 0 ] && return 1
 touch $LOG_DIR/$1
 [ $? -ne 0 ] && return 1
 chmod 666 $LOG_DIR/$1
 [ $? -ne 0 ] && return 1

just mv it and touch a new one.
The problem is the logger can’t wirte anything in the
file of plus_dig_cname.log. The logging can’t work.

Maybe it can be solved it by:

with open( "plus_dig_cname.log", "w" ):
               pass

this way can get a new log file by Python. But i want to get the new log file by Bash.

So, why the logging can’t work after “mv touch chmod”?

Thank you

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

    Use a RotatingFileHandler to have this handled for you.

    For example:

    MAX_SIZE = 300 * 1024 * 1024
    LOG_PATH = fdoc_log + "/plus_dig_cname.log"
    fh = logging.handlers.RotatingFileHandler(LOG_PATH, maxBytes=MAX_SIZE, backupCount=5)
    

    This will create 5 backups of 300MB each.

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

Sidebar

Related Questions

I want to create log.c file with containing info(), debug() and error() functions. These
I have a property-file with strings inside, formatted in this way: audit.log.events.purged=The audit events
I'm trying create a log specifically for logging user account activity. I created this
I want to create log file for my flex application. That is the file
I need to create a log file containing HTML (tables, etc). It seems that
I have to create a log file for all internet connections made by PC.
I'm trying to create a new log file every hour with the following code
I am trying to use 'git log --pretty=tformat' to create xml file log. However
I need to create a batch file which will copy web log files from
I want to create a series of files under log directory which every file

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.