[BUG] Logging does not work again with pennylane
See original GitHub issueExpected behavior
Similar to this issue, I was expecting writing logs into a log file by setting:
logging.basicConfig(
format='%(asctime)s - %(levelname)s: %(message)s',
filename='log.txt',
filemode='w'
)
Actual behavior
However, the logger still outputs everything to stdout. I guess that PennyLane may overwrite my logging setting.
Additional information
No response
Source code
# Some qml functions I used
qml.BasisStatePreparation
qml.StronglyEntanglingLayers
qml.AngleEmbedding
qml.StronglyEntanglingLayers
qml.expval
qml.PauliZ
qml.StronglyEntanglingLayers.shape
qml.device
qml.QNode
qml.qnn.TorchLayer
Tracebacks
No response
System information
Name: PennyLane
Version: 0.19.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: None
Author-email: None
License: Apache License 2.0
Location: /home/qlan3/miniconda3/lib/python3.9/site-packages
Requires: scipy, semantic-version, autograd, pennylane-lightning, cachetools, networkx, autoray, toml, numpy, appdirs
Required-by: PennyLane-Lightning
Platform info: Linux-5.8.0-44-generic-x86_64-with-glibc2.31
Python version: 3.9.5
Numpy version: 1.20.3
Scipy version: 1.7.1
Installed devices:
- default.gaussian (PennyLane-0.19.1)
- default.mixed (PennyLane-0.19.1)
- default.qubit (PennyLane-0.19.1)
- default.qubit.autograd (PennyLane-0.19.1)
- default.qubit.jax (PennyLane-0.19.1)
- default.qubit.tf (PennyLane-0.19.1)
- default.qubit.torch (PennyLane-0.19.1)
- default.tensor (PennyLane-0.19.1)
- default.tensor.tf (PennyLane-0.19.1)
- lightning.qubit (PennyLane-Lightning-0.19.0)
- I have searched existing GitHub issues to make sure the issue does not already exist.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Release notes — PennyLane 0.28.0 documentation
An exception is BasisEmbedding , which is not broadcastable. Improvements. The qml.math.expand_matrix() method now allows the sparse matrix representation of an ...
Read more >PennyLane - PyPI
PennyLane is a Python quantum machine learning library by Xanadu Inc. ... Issue Tracker: https://github.com/PennyLaneAI/pennylane/issues.
Read more >ReportingBugs - Community Help Wiki
Many times, a problem you're running into isn't a bug in Ubuntu, ... or if you don't have the time to learn how...
Read more >The Beat Bugs - Penny Lane paroles | Musixmatch
Stop and say hello On the corner is a banker with a motorcar The little children laugh at him behind his back And...
Read more >Chat log from the meeting on 2010-08-31 - OpenSimulator
[18:15] Justin Clark-Casey: if it doesn't work in the real world it will just ... [18:24] Penny Lane: I'm just worried about Opensim...
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

So as a closing comment I would like summarize:
When using logging and PennyLane, one should make sure to import and setup logging first BEFORE importing PL to ensure the logger settings are not ignored.
@josh146, after looking into this, it seems that the logging we currently do is not used anywhere else in the codebase. In fact, we don’t log to file at all. It might be worth removing completely. Let me know what you think.
@raghavven and @qlan3,
I just want to confirm if there are any action items here? From the above thread it seems you were able to get your loggers working by swapping the order of the imports and/or removing the line from
configuration.pywhich called the logger in the first place?Thanks again for pointing this out! Let me know if you are seeing any additional issues around this bug and I can address this it in a bug fix PR, otherwise if it was just a matter of keeping an eye on which order the logger is being imported then we can close the issue here 👍🏼
Cheers,