django日志记录配置:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'debug.log',
},
},
'loggers': {
'django': { },
'setting':{
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
debug.log中的错误:
Watching for file changes with StatReloader
Waiting for apps ready_event.
Apps ready_event triggered. Sending autoreload_started signal.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/admin/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/sessions/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/messages/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/auth/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/contenttypes/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/django/contrib/staticfiles/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/rest_framework/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/user/locale with glob **/*.mo.
Watching dir /home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/corsheaders/locale with glob **/*.mo.
(0.001) QUERY = 'SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"' - PARAMS = (); args=()
Watching for file changes with StatReloader
Waiting for apps ready_event.
Apps ready_event triggered. Sending autoreload_started signal.
我期望的错误:
File "/home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/pymongo/database.py", line 552, in collection_names
ReadPreference.PRIMARY) as (sock_info, slave_okay):
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/pymongo/mongo_client.py", line 904, in _socket_for_reads
with self._get_socket(read_preference) as sock_info:
File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/pymongo/mongo_client.py", line 868, in _get_socket
server = self._get_topology().select_server(selector)
File "/home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/pymongo/topology.py", line 214, in select_server
address))
File "/home/fractaluser/Desktop/Dev/consumerhub/env/lib/python3.6/site-packages/pymongo/topology.py", line 189, in select_servers
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: 10.4.9.25:80: timed out
上面的错误出现在我的控制台中,但是没有写在我的debug.log文件中。 它只是在写一些基本的东西,而不是实际的错误。
我已共享记录器和日志文件的设置conf。
答案 0 :(得分:0)
请在您的日志记录中添加它:
with open('logs/older_output.txt') as f1, open('logs/newer_output.txt') as f2:
old_lines = set(f1)
new_lines = [line for line in f2 if line not in old_lines]