Logger printing the logs twice to console
See original GitHub issueimport logging
from sacred import Experiment
from sacred.settings import SETTINGS
SETTINGS.CAPTURE_MODE = 'no'
ex = Experiment('test')
logger = logging.getLogger('test')
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
@ex.automain
def main():
logger.info("hahah")
output:
2018-04-12 04:32:24,363 - test - WARNING - No observers have been added to this run
WARNING - test - No observers have been added to this run
2018-04-12 04:32:24,363 - test - INFO - Running command 'main'
INFO - test - Running command 'main'
2018-04-12 04:32:24,364 - test - INFO - Started
INFO - test - Started
2018-04-12 04:32:24,364 - test - INFO - hahah
INFO - test - hahah
2018-04-12 04:32:24,364 - test - INFO - Completed after 0:00:00
INFO - test - Completed after 0:00:00
Why is everything getting printed twice? One with date and one without? Since my log can be huge, I don’t want to send them to observers.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
log messages appearing twice with Python Logging
You are calling configure_logging twice (maybe in the __init__ ... But if we had a parent logging object, then it will be printed...
Read more >Duplicate Logging Messages in Python - jdhao's digital space
Option 2: Simply do not use root logger in main.py . For example, we can get another logger by using another_logger = logging.getLogger('main') ......
Read more >Why Log statement is printing twice in console log file.
In some cases, logging output is executed twice to a log destination. This is a side effect of the Log4j additivity which is...
Read more >4.2 - Console.log outputting everything twice.
The reason everything prints twice is because you're looping over the cards' properties (which there are two of) and then printing the suit...
Read more >This Is Why React Prints All Console Logs Twice - YouTube
Full Video: https://youtu.be/XUwzASyHr4QSorry about the bad audio quality. My computer changed my mic to use my webcam mic instead of my ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I found the solution for my case, (tensorflow 1.8.0)
simply works.
It seems that the only problem is that
sacred.utils.create_basic_stream_logger()has a hard coded format. The proper solution would be to make the format parametrizable (and provide this as default). In my case copying the function and providing different format worked well (even with other modules and tensorflow. Custom format, no log duplication.