Forum Moderators: phranque

Message Too Old, No Replies

Messages of level 'info' are shown as 'error' in error log

         

Sudheer Kalla

9:44 am on Apr 18, 2015 (gmt 0)

10+ Year Member



Hi All,

Iam using apache server and I have the following lines in my 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!

Iam using python

lucy24

6:49 pm on Apr 18, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You forgot to say which Apache version you're using. It's also not clear which errors elicit this message: all errors, "info"-class errors only, or everything from "info" on up --or "info" on down.

:: detour to check levels so I don't have to look them up again ::

emerg
alert
crit
error
warn
notice
info
debug
Try a simple test, please. Add another three-line block, duplicating the one you've got. But this time replace the word "info" with something else such as "warn" or "notice".

I've got a lurking suspicion that the problem is actually something entirely different from what it appears to be, but that part will have to wait for someone who speaks Apache.

Sudheer Kalla

8:31 am on Apr 20, 2015 (gmt 0)

10+ Year Member



The following is the version of apache
Server version: Apache/2.2.22 (Ubuntu)

All levels of classes(info,warn,crit,alert..etc) are logged as [error] in the error log.

lucy24

3:43 pm on Apr 20, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, but do they all come with the text string "This is info" or "This is warn"?

5kKate

7:04 pm on Apr 21, 2015 (gmt 0)

10+ Year Member



Not sure why this is happening but I usually find it easier to have python log to a separate file. Then the logs aren't mixed with apache errors. You can do this by adding a syslog or file handler. This might also fix the issue of the log level being wrong since python is writing it directly.

handler = logging.FileHandler('/var/log/myapp/myapp.log')
logger.addHandler(handler)

phranque

12:39 am on Apr 22, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Sudheer Kalla!

But this time replace the word "info" with something else such as "warn" or "notice".

or try using
LOG.log(info,msg)
instead and see if that works.