| Author | 
  | 
Sudheer Kalla
 
 
  Joined: 03 Apr 2015 Posts: 2 Location: India
  | 
 Posted: Fri 03 Apr '15 13:50    Post subject: Messages of level 'info' are shown as 'error' in error log | 
     | 
 
  | 
 
Hi All, 
 
 
I using apache server and I have the following lines in my code.
 
 
 	  | Code: | 	 		  
 
import logging
 
 
LOG = logging.getLogger(__name__)
 
msg = "This is level info"
 
LOG.info(msg)
 
 | 	  
 
 
Here the message "This is level info" must come in level 'info' in the apache2/error.log
 
But I get the message in file "apache2/error.log" as follows:
 
 
[Thu Apr 02 12:57:59 2015] [error] This is level info
 
 
 
Since the message is logged with LOG.info it is expected to be of class [info]
 
Please provide us a solution.
 
 
Thank you in advance!   | 
 
  | 
| Back to top | 
 | 
5kKate
 
  
  Joined: 20 Mar 2015 Posts: 6
 
  | 
 Posted: Fri 03 Apr '15 19:49    Post subject:  | 
     | 
 
  | 
 
Is this PHP? You should check your php.ini on how you've configured logging.
 
 
Open the php.ini file, in this case for apache:
 
 
sudo vim /etc/php5/apache2/php.ini
 
Configure it to log over syslog by uncommenting this line:
 
 
#forward log events to syslog
 
error_log = syslog
 
 
If you have that line that's why it's going to your error log. You can also use a framework like monolog if you want more flexibility to configure destinations. | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7442 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Sat 04 Apr '15 22:31    Post subject:  | 
     | 
 
  | 
 
I guess that is Python? 
 
 
if yes check 
 
 
.setLevel() and .getEffectiveLevel | 
 
  | 
| Back to top | 
 | 
Sudheer Kalla
 
 
  Joined: 03 Apr 2015 Posts: 2 Location: India
  | 
 Posted: Mon 06 Apr '15 12:22    Post subject:  | 
     | 
 
  | 
 
Yes this is Python.
 
getEffictiveLevel() gives me output as 10.
 
 
I have tried to set different the levels using setLevel(), but in all the cases I get the same problem.
 
I also tried to log by different levels -
 
 	  | Code: | 	 		  LOG.info(msg)
 
LOG.error(msg)
 
LOG.warning(msg)
 
LOG.critical(msg)
 
LOG.exception(msg) | 	  But I get the same output:
 
 
[Mon Apr 06 10:14:20 2015] [error] This is level info 
 
[Mon Apr 06 10:14:20 2015] [error] This is level info 
 
[Mon Apr 06 10:14:20 2015] [error] This is level info 
 
[Mon Apr 06 10:14:20 2015] [error] This is level info 
 
[Mon Apr 06 10:14:20 2015] [error] This is level info  | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7442 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Mon 06 Apr '15 22:06    Post subject:  | 
     | 
 
  | 
 
I have no python installed nor do I know it, but I wonder since the docs[1] says that a 10 is debug mode. Do you set that in your scripte somewhere? 
 
 
 
[1] https://docs.python.org/2/library/logging.html | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7442 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Tue 07 Apr '15 10:47    Post subject:  | 
     | 
 
  | 
 
On my workstation I tried the following
 
 
in my vhost 
 
 	  | Code: | 	 		  
 
      <Files ~ "\.py$">
 
         Options Indexes ExecCGI
 
         AddHandler cgi-script .py
 
      </Files>
 
 | 	  
 
 
 
 	  | Code: | 	 		  #!/Python27/python
 
 
import logging
 
logging.warning('Watch out!') # will print a message to the console
 
logging.info('I told you so') # will not print anything
 
 
print "Content-type: text/html"
 
print
 
print "<html><head>"
 
print ""
 
print "</head><body>"
 
print "Hello."
 
print "</body></html>" | 	  
 
 
in the error log
 
 	  | Code: | 	 		  
 
[Tue Apr 07 10:44:24.483709 2015] [cgi:error] [pid 5900:tid 1840] [client ::1:62595] AH01215: WARNING:root:Watch out!\r: C:/Users/mario/work/test.py, referer: http://localhost/
 
 | 	 
  | 
 
  | 
| Back to top | 
 |