Django logging error: Log file not created - python

While running Django project, I am getting the following error:
Unhandled exception in thread started by <function wrapper at 0x7fe72b054b50>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/usr/local/lib/python2.7/dist-packages/django/utils/log.py", line 86, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python2.7/logging/config.py", line 794, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 576, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'ap_migration_log': [Errno 2] No such file or directory: '/home/dg/Desktop/project_dir/django_project/
module_a/management/commands/log/ap_migration_log'
One solution I found on stackoverflow is to create these files and then this error will not occur. But, why can't Django create log files on its own when required? Is there any config setting or command to make sure that logging file isn't created manually?

Make sure that if you're writing the logs to /my/log/dir/log.txt, that path exists along with the empty log.txt file. Also make sure that your directory has the right permissions to perform CRUD operations. Same goes to the file.
It's best practice to store log files in /var/log/ directory.
Have a look at https://docs.djangoproject.com/en/3.0/topics/logging/#configuring-logging for examples on how Django logging works.

Related

Django runserver hangs at “System check identified no issues (0 silenced).” for a while

I am not able to start manage.py runserver 0.0.0.0:8000. I am using a MySQL database and I have imported all the required modules. I am trying to run quite basic application.
I am running python 3.7.3 on windows 10. Here is the error I am getting:
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x0000000005A89E18>
Traceback (most recent call last):
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\utils\aut
oreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\core\mana
gement\commands\runserver.py", line 120, in inner_run
self.check_migrations()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\core\mana
gement\base.py", line 442, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\loader.py", line 49, in __init__
self.build_graph()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\migrat
ions\recorder.py", line 62, in applied_migrations
return {tuple(x) for x in self.migration_qs.values_list('app', 'name')}
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\models
\query.py", line 268, in __iter__
self._fetch_all()
File "C:\Users\flgferre\Desktop\webapp\venv\lib\site-packages\django\db\models
\query.py", line 1186, in _fetch_all
self._result_cache = list(self._iterable_class(self))
MemoryError
I've seen a similar MemoryError around here, but I'm not using SQLite and I've already tried using DEBUG=False.
Thank you in advance for the help.
I have just solved my problem by checking my dependencies. I believe that the code was stuck because of some kind of incompatibility among packages.

Django Unhandled exception in thread started by at python manage.py runserver

I am running Django project on linux(Ubuntu16.04), Recently i was uninstall my os and reinstall the same OS on my system.I have some django project previously it was working very well, after installing the os and All django packages It is not running but however if i create any new django project with django-admin startproject name.. it works .
The following error i am getting
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f7ceceb5730>
Traceback (most recent call last):
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
six.reraise(*_exception)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/balu/Desktop/yottaasys/django-hrms/hrm_env/lib/python3.5/site-packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python3.5/logging/config.py", line 795, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python3.5/logging/config.py", line 490, in configure
raise ValueError("dictionary doesn't specify a version")
ValueError: dictionary doesn't specify a version
you are missing 'version' from your logging settings.
https://docs.python.org/3.6/library/logging.config.html#dictionary-schema-details

ValueError: Unable to configure handler 'null': Cannot resolve 'django.utils.log.NullHandler': No module named NullHandler

I am getting error while running python manage.py runserver of all the django projects which i have. I am using django 1.6.
My projects were running perfectly fine. Then I installed django-subdomains and django-gcm packages in my virtual environment for some implementations and the error started showing up in all the projects (may be this has something to do with the error so I mentioned). Then I uninstalled the packages but the error remains
MY error stack trace is:
Unhandled exception in thread started by <function wrapper at 0xabcddf4>
Traceback (most recent call last):
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/shivam/virtual/venv/local/lib/python2.7/site-packages/django/utils/log.py", line 71, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 575, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'null': Cannot resolve 'django.utils.log.NullHandler': No module named NullHandler

Django error: too many open files

I'm using Anaconda python and I'm trying to run a simple Django server using the official documentation. When I run python manage.py runserver I get this error
Nuseirs-MacBook-Pro:anothertry nyassin$ python manage.py runserver
Validating models...
0 errors found
November 06, 2013 - 18:27:10
Django version 1.7.dev20131105182658, using settings 'anothertry.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/nyassin/django-trunk/django/core/management/__init__.py", line 416, in execute_from_command_line
utility.execute()
File "/Users/nyassin/django-trunk/django/core/management/__init__.py", line 408, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/nyassin/django-trunk/django/core/management/base.py", line 244, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/nyassin/django-trunk/django/core/management/base.py", line 291, in execute
output = self.handle(*args, **options)
File "/Users/nyassin/django-trunk/django/core/management/commands/runserver.py", line 76, in handle
self.run(*args, **options)
File "/Users/nyassin/django-trunk/django/core/management/commands/runserver.py", line 85, in run
autoreload.main(self.inner_run, args, options)
File "/Users/nyassin/django-trunk/django/utils/autoreload.py", line 359, in main
reloader(wrapped_main_func, args, kwargs)
File "/Users/nyassin/django-trunk/django/utils/autoreload.py", line 325, in python_reloader
reloader_thread()
File "/Users/nyassin/django-trunk/django/utils/autoreload.py", line 304, in reloader_thread
if fn():
File "/Users/nyassin/django-trunk/django/utils/autoreload.py", line 217, in kqueue_code_changed
new_descriptors = set(open(filename) for filename in new_filenames)
File "/Users/nyassin/django-trunk/django/utils/autoreload.py", line 217, in <genexpr>
new_descriptors = set(open(filename) for filename in new_filenames)
IOError: [Errno 24] Too many open files: '//anaconda/lib/python2.7/lib-dynload/resource.so'
Any ideas what might be causing this?
It's an operating system error. The maximum number of open files is limited. Try to find where you open files and forget to close them.
Open less file descriptors at once.
set(open(filename) for filename in new_filenames)
is where the error occurs.

DjangoAppEngine TestApp

Need some help starting up the djangoappengine testapp.I followed the instructions at http://www.allbuttonspressed.com/projects/djangoappengine, but when I run ./manage.py runserver . while in the project directory I get the following error:
WARNING 2011-03-24 12:23:21,994 datastore_file_stub.py:657] Could not read datastore
data from /media/disk/Projex/AppEngineApp/app/.gaedata/datastore
Error: option --rdbms_sqlite_path not recognized
Runs a development application server for an application.
manage.py [options] <application root>__
When I try and comment the ' 'rdbms_sqlite_path': os.path.join(DATA_ROOT, 'rdbms'),' line in app/djangoappengine/db/base.py I get the following error:
WARNING 2011-03-24 12:26:07,239 datastore_file_stub.py:657] Could not read datastore
data from /media/disk/Projex/AppEngineApp/app/.gaedata/datastore
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/media/disk/Projex/AppEngineApp/app/django/core/management/__init__.py", line 438,
in execute_manager
utility.execute()
File "/media/disk/Projex/AppEngineApp/app/django/core/management/__init__.py", line 379,
in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/media/disk/Projex/AppEngineApp/app/djangoappengine/management/commands/runserver.py",
line 94, in run_from_argv
start_dev_appserver(argv)
File
"/media/disk/Projex/AppEngineApp/app/djangoappengine/management/commands/runserver.py",
line 81, in start_dev_appserver
dev_appserver_main.main([progname] + args + [PROJECT_DIR])
File "/usr/local/gaepy/google/appengine/tools/dev_appserver_main.py", line 426, in main
static_caching=static_caching)
File "/usr/local/gaepy/google/appengine/tools/dev_appserver.py", line 3820, in
CreateServer
server = HTTPServerWithScheduler((serve_address, port), handler_class)
File "/usr/local/gaepy/google/appengine/tools/dev_appserver.py", line 3840, in __init__
request_handler_class)
File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
self.server_bind()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.6/SocketServer.py", line 411, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.gaierror: [Errno -5] No address associated with hostname
Anyone experienced this issue ?
You probably already solved this, but for future users:
The warning can have multiple causes:
data store is empty, in that case ignore
wrong permissions on the datastore files
data corruption issue
The error can be solved by updating djangoappengine
Update to the latest version of google app engine.

Categories

Resources