logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Messages of level 'info' are shown as 'error' in error log
Author
Sudheer Kalla



Joined: 03 Apr 2015
Posts: 2
Location: India

PostPosted: Fri 03 Apr '15 13:50    Post subject: Messages of level 'info' are shown as 'error' in error log Reply with quote

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! Smile
Back to top
5kKate



Joined: 20 Mar 2015
Posts: 6

PostPosted: Fri 03 Apr '15 19:49    Post subject: Reply with quote

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: 7306
Location: Germany, Next to Hamburg

PostPosted: Sat 04 Apr '15 22:31    Post subject: Reply with quote

I guess that is Python?

if yes check

.setLevel() and .getEffectiveLevel
Back to top
Sudheer Kalla



Joined: 03 Apr 2015
Posts: 2
Location: India

PostPosted: Mon 06 Apr '15 12:22    Post subject: Reply with quote

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: 7306
Location: Germany, Next to Hamburg

PostPosted: Mon 06 Apr '15 22:06    Post subject: Reply with quote

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: 7306
Location: Germany, Next to Hamburg

PostPosted: Tue 07 Apr '15 10:47    Post subject: Reply with quote

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


Reply to topic   Topic: Messages of level 'info' are shown as 'error' in error log View previous topic :: View next topic
Post new topic   Forum Index -> Apache