1

I am writing unit testcase in python. I want to create custom logging in python. When I run a testcase, I want two new files to be created, one saves info logs and the other saves debug logs. I am able to achieve this in config file. But my files names should be dynamic with a time stamp. How I can able to achieve this?

For example if testcase.py is run, log-12-2-2013_23:30:31.log and debug_log-12-2-2013_23:30:31.log

Also for each run, new files to be created.

Thanks,

1
  • Easier to dump it into a single log file and filter using a separate tool. I generally use perl, but you may find python easier.
    – hd1
    Commented Jun 12, 2013 at 17:12

1 Answer 1

1

Maybe you could try using logging.handlers.RotatingFileHandler: https://docs.python.org/2/library/logging.handlers.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.