Note the following when using global logs in Python:
After using uliweb to develop soap webservice, werkzeug logs are lost while uliweb is started.
Normal logs:
Copy codeThe Code is as follows: [INFO] * Loading DebuggedApplication...
[INFO] * Running on http: // localhost: 8000/
[INFO] * Restarting with reloader
[INFO] * Loading DebuggedApplication...
Abnormal logs:
Copy codeThe Code is as follows: [INFO] * Loading DebuggedApplication...
[INFO] * Loading DebuggedApplication...
In fact, all the INFO and below-level logs related to werkzeug cannot be seen, which is so strange that the issue was submitted decisively.
In addition, after I create a new project and app, there is no log loss problem, so I suspect it is because I upgraded from uliweb 0.1.3 to 0.1.4, my project was created using 0.1.3, and I have never paid attention to the log issue before. However, after receiving a response from limodou, I denied this point.
- When creating a project, uliweb does not generate something like Django manage. py, that is, some configuration files and startup files such as settings. py are irrelevant to the version.
Think about it. The difference between my project and the new project is that settings. ini is richer, and pysimplelib is used. Well, let's track it from the source code.
I have read the uliweb built-in zerkzeug code and the log creation is clear here.
Uliweb/lib/werkzeug/serving. py
Copy codeCode: 112 if not logging. root. handlers and _ logger. level = logging. NOTSET:
113 _ logger. setLevel (logging. INFO)
114 handler = logging. StreamHandler ()
115 _ logger. addHandler (handler) [code]
When global logging. the Handler or werkzeug defined in the root does not define the log level. werkzeug sets the log level of its logger to info, while the location where the werkzeug log is printed happens to use the info level.
[Code] [INFO] * Running on http: // localhost: 8000/
[INFO] * Restarting with reloader
That is to say, the werkzeug log cannot be output because other logging handler has been defined.
Result In grep pysimplelib
Copy codeThe Code is as follows:./client. py: 33: logging. basicConfig (format = '% (levelname) s: % (message) s', level = logging. WARNING)
./Simplexml. py: 27: logging. basicConfig (format = '% (levelname) s: % (message) s', level = logging. WARNING)
./Transport. py: 30: logging. basicConfig (format = '% (levelname) s: % (message) s', level = logging. WARNING)
Okay, this guy is working. After the three lines of code are commented out, werkzeug logs are output normally.
This is not a uliweb issue. The global design of the pysimplesoap library modification should be given an issue, which should be closed.
Here is a workaround, which is added in apps/settings. ini.
Copy codeThe Code is as follows: [LOG. Loggers]
Werkzeug = {'pagate': 0, 'level': 'info', 'format': 'format _ simple '}
Of course, it is recommended that limodou set the Log Level of zerkzeug in default_settings.ini to info by default, because this problem is so strange. After all, the default Log Level in werkzeug is info.
Well, let's review that due to the global log level covered in pysimplesoap, werkzeug cannot enter logs lower than warning. Therefore, when developing and opening the python library, leave the log in your namespace and do not touch the global logging settings. This will cause troubles to others.