OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Cannot log in PythonAnywhere from Flask webapp

  • Thread starter Thread starter Csaba Faragó
  • Start date Start date
C

Csaba Faragó

Guest
I created a simple Python Flask web application, but cannot add log entries. Here are what I tried:

  • print('mylog') alone, and in combination with sys.stdout.flush()
  • print('mylog', flush=True)
  • print('mylog', file=sys.stderr)
  • import logging; logger = logging.getLogger(__name__); logger.info('mylog')

I checked server.log, error.log and even access.log. I waited for a while, refreshed all of them, but could not find any of the above entries in any of the 3 log files.

I put these both to the beginning of the main function and around the error I experience. That Python level error is logged into error.log, so the logging itself somehow works. My problem is that I cannot add custom log entries.

I also tried to write logs directly into a file like this: print('mylog', file=open('log.txt', 'a')), but that did not work either.
<p>I created a simple Python Flask web application, but cannot add log entries. Here are what I tried:</p>
<ul>
<li><code>print('mylog')</code> alone, and in combination with <code>sys.stdout.flush()</code></li>
<li><code>print('mylog', flush=True)</code></li>
<li><code>print('mylog', file=sys.stderr)</code></li>
<li><code>import logging; logger = logging.getLogger(__name__); logger.info('mylog')</code></li>
</ul>
<p>I checked <code>server.log</code>, <code>error.log</code> and even <code>access.log</code>. I waited for a while, refreshed all of them, but could not find any of the above entries in any of the 3 log files.</p>
<p>I put these both to the beginning of the main function and around the error I experience. That Python level error is logged into <code>error.log</code>, so the logging itself somehow works. My problem is that I cannot add custom log entries.</p>
<p>I also tried to write logs directly into a file like this: <code>print('mylog', file=open('log.txt', 'a'))</code>, but that did not work either.</p>
 
Top