Closed JiafengtTang closed 1 year ago
Hi @tjfstu, I am unable to reproduce this. The logs look the same with and without Opacus. https://colab.research.google.com/drive/13sICPqRucB7Q77YPlml5m-Q8YXpoq4xq?usp=sharing
Could you share your code in a colab so that we can debug it more effectively?
Thank you for reply. When running the log file, I encountered the previous problem. This file is attached.
唐甲锋 | |
---|---|
@. | ---- Replied Message ---- | From | Karthik @.> | | Date | 1/26/2023 13:27 | | To | @.> | | Cc | @.> , @.***> | | Subject | Re: [pytorch/opacus] Using 'from opacus import PrivacyEngine' and 'import logging', the formatter of print Information was set automatically. (Issue #553) |
Hi @tjfstu, I am unable to reproduce this. The logs look the same with and without Opacus. https://colab.research.google.com/drive/13sICPqRucB7Q77YPlml5m-Q8YXpoq4xq?usp=sharing
Could you share your code in a colab so that we can debug it more effectively?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Hi @tjfstu , I don't know what "running the log file" means, nor do I see any file attached. Could you share the code in colab instead? This will ensure that the issue is not due to any system idiosyncrasies. You can clone my colab and add your code. :)
Hi @karthikprasad, thank you for your reply. I also found that when I run the code in the colab, the issue didn't occur. I doubt there may be some system idiosyncrasies, which caused this issue. Thank you for your reply again.
🐛 Bug
The examples are as follows: 1.Importing opacus: import os import logging from opacus import PrivacyEngine
def get_logger(logpath, filepath, package_files=[], displaying=True, saving=True, debug=False): logger = logging.getLogger(name) if debug: level = logging.DEBUG else: level = logging.INFO logger.setLevel(level) if saving: info_file_handler = logging.FileHandler(logpath, mode="a") info_file_handler.setLevel(level) logger.addHandler(info_file_handler) if displaying: console_handler = logging.StreamHandler() console_handler.setLevel(level) formatter = logging.Formatter('%(asctime)s -- [%(levelname)s] -- %(message)s') # '%(asctime)s - %(name)s - %(levelname)s - %(message)s' console_handler.setFormatter(formatter) logger.addHandler(console_handler) logger.info(filepath) with open(filepath, "r") as f: logger.info(f.read())
log = get_logger(logpath='../exp/log.txt', filepath=os.path.abspath(file)) log.info('fasd')
***the print result is: 2023-01-11 20:26:17,679 -- [INFO] -- fasd 01/11/2023 20:26:17:INFO:fasd
***The opacus may have automatically set the logging print formatter, how do I cancel this?