Comments (5)
Sorry for the noise, I was not paying close enough attention to where this was opened against.
from ibmi-oss-docs.
My guess is that you need to adjust the logging configuration with the opened log file, since it probably holds a handle to the original sys.stdout or sys.stderr even though you've replaced them.
You might want to try calling logging.basicConfig before calling any logging functions and see if that fixes it, eg.
import logging
import sys
logIFSFileName = '/path/to/log/file.txt'
sys.stdout = sys.stderr = open(logIFSFileName, 'w')
logging.basicConfig(stream=sys.stdout)
from ibmi-oss-docs.
It worked with one exception. If there is syntax error. it got reported in QPRINT.
example:
QPRINT output.
File "/home/sgonchigar/python/test_logging_v1.py", line 22
^
SyntaxError: unexpected EOF while parsing
from ibmi-oss-docs.
Well the problem there is that the syntax error detection happens before the code is run, so the code to do the redirect hasn't run yet.
You could use something like tee
instead, which will redirect stdout to a log file and stdout, eg.
QSH CMD('python3 myscript.py 2>&1 | tee myfile.log')
The above example would redirect all output from myscript.py to myfile.log as well as sending it to stdout for the job.
from ibmi-oss-docs.
Thank you. That worked!
from ibmi-oss-docs.
Related Issues (20)
- [Fixup] Add FAQ entry for GCC missing errors
- [New] Document Readline applications not working in 5250
- CONTRIBUTION file
- [New] Jenkins with/on IBM i
- [Fixup] Yum connection troubleshooting
- [New] Page on monitoring solutions
- Node development - can't use Jest or Nodemon anymore HOT 2
- Add link for PHP
- [New] Document CHOKIDAR_USEPOLLING for working around lack of fs.watch HOT 2
- [New] MariaDB 10.6.x migration guide
- [New] Add Golang Page
- [Fixup] Node.js Page: Use update-alternatives rather than nodever
- Installing Python Packages references an invalid yum command HOT 1
- [New] Node.js os.uptime enosys
- [New] Add documentation for pip HTTP proxy configuration
- Where does [IBM][System i Access ODBC Driver] search for certificates?
- reportlab installation using pip3 reporting error in python3.9 HOT 1
- IBMi and AIX package. HOT 6
- ibm-access driver not installable on Ubuntu 23.10 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ibmi-oss-docs.