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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:35:15+00:00 2026-06-13T12:35:15+00:00

I am using the logging module of python. In the case of unit tests

  • 0

I am using the logging module of python.

In the case of unit tests (we use py.test) every time tests are launched, some log information goes to a certain file. In the integration server, everytime someone pushes code (we also use git 🙂 we run the tests.

The problem is that once the file is created, by user A when user B tries to run the tests, the tests will fail as user B has no permission to write on the same file.

So far, we have changed the file permissions manually, but looks like a dirty solution. Also we though of creating a log file per user, but again, does not feel right.

Our code for the logging in the tests is

logging.basicConfig(level=logging.DEBUG,
    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
    datefmt='%m-%d %H:%M',
    filename='/tmp/py.test.log',
    filemode='w')
log.setLevel(logging.DEBUG)
log.addHandler(logging.StreamHandler())

Is there a way to avoid this problem? Maybe using filemode = ‘a’ could do it, but lets assume I want a new file everytime (to be honest this is more curiosity that a real problem, still I want to do it right)

Thanks 🙂

  • 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-13T12:35:15+00:00Added an answer on June 13, 2026 at 12:35 pm

    It sounds like the logging process is trying to write on top of an existing file that’s owned by another user. Here is a procedure for allowing group access for the group loggroup to the directory logdir.

    1. Make the containing directory group-writable.

      $ chgrp loggroup logdir
      $ chmod g+w logdir
      
    2. Set the setgid bit on logdir. That makes new files in logdir always owned by the group. Otherwise, new files are owned by the creator’s group.

      $ chmod g+s logdir
      
    3. Ensure all logging users belong to loggroup.

      $ usermod -a -G loggroup myuser
      
    4. Ensure all writing processes have the right umask so they can make newly created files group-writable.

      $ umask 0002
      
    5. Now all members of the loggroup group can create files in logdir and overwrite each other’s files.

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

Sidebar

Related Questions

I have been using the python logging module for quite some time now, but
I would like to use the python logging module to log all of the
I have a python logger set up, using python's logging module. I want to
I'm using Logging ( import logging ) to log messages. Within 1 single module,
I'm trying to configure logging for a Django app using the Python logging module.
I am using python's logging module in a django project. I am performing the
I'm using the standard python (2.5.2) logging module, specifically the RotatingFileHandler , on a
I am using the logging module in Python to write debug and error messages.
I'm using Python logging, and for some reason, all of my messages are appearing
I am using logging module of python. How can I access the handlers defined

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.