Logging¶
There are two main log files. (Any particular plugin may also create their own log file.)
Log.txt: The standard X-Plane Log file
XPPython3Log.txt: Standard output for python plugins
If you have errors running python plugins,
Check Log.txt. Make sure python and the python plugin are installed correctly. If not, there will be a message in Log.txt, and XPPython3Log.txt will not be created. Verify it’s Python3, not Python2 getting loaded.
Check XPPython3Log.txt. Most python coding errors / exceptions will be reported in this log.
For common installation error messages, see Common Installation Errors.
Log.txt¶
Some messages go to Log.txt. Specifically, when python plugin itself is loaded, something like:
Loaded: /Volumes/C/X-Plane/Resources/plugins/XPPython3/mac_x64/XPPython3.xpl (xppython3.main).
followed by:
[XPPython3] Starting 4.0.0 - for Python 3.11 (compiled: 30z01f0)... Logging to XPPythonLog.txt
[XPPython3] Python runtime initialized 3.11.1
If XPPython3 cannot load, you’ll see an error in this log file.
XPPython3Log.txt¶
Python messages go to <XP>/XPPython3Log.txt
1. You can change location of this logfile
by setting environment variable XPPYTHON3_LOG
. Log is re-written each time 2. If you want to preserve
the contents of the logfile, set environment variable XPPYTHON3_PRESERVE
. Optionally, these
values can be set in the initialization file, see Preferences File. (The final location
of the logging file will be indicated in Log.txt
which will indicated the name of the file on python startup.)
If you’ve changed the log file environment variable, the new log file will be indicated in the
message in Log.txt
file (above). If the python log file cannot be opened,
or XPPYTHON3_LOG
is set to an empty value, logging will be to standard out.
Python Log always contains:
[XPPython3] Version 4.0.0 - for Python 3.11 Started -- Mon Oct 31 13:24:28 2022 [XPPython3] Python shared library loaded: /Library/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib
Then the script folder(s) are scanned. If the folder cannot be found it’s listed (not an error really, but just to let you know). This includes scanning for aircraft-specific plugins:
Can't open <folder> to scan for plugins.
On each python plugin startup, we print:
[XPPython3] PI_<plugin> initialized. [XPPython3] Name: <plugin name> [XPPython3] Sig: <plugin signature> [XPPython3] Desc: <plugin description>
Successful shutdown will end with:
[XPPython3] Stopped. Mon Oct 31 13:32:23 2022
Internally, we map both <stdout> and <stderr> for python to this python log file. This allows you
to use the python print()
function for output. You can redirect output to
a different file as specified above, including to Log.txt
, which will result in information being visible
in the X-Plane Developer Console (Developer->Toggle Dev Console).
If you do this, be sure to also set XPPYTHON3_PRESERVE
to a value so that
python merely appends information to Log.txt
.:
shell% XPPYTHON3_LOG=Log.txt
shell% XPPYTHON3_PRESERVE=1
shell% export XPPYTHON3_LOG XPPYTHON3_PRESERVE
You can also using standard python logging module. By default it writes to <stderr>, which goes to the python log file:
import logging
logging.basicConfig(format='%(message)s')
log = logging.getLogger(__name__)
log.warning("Hello World")
Footnotes