Welcome to WebmasterWorld Guest from 3.93.74.227

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

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

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

New User

joined:Apr 18, 2015
posts: 1
votes: 0


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
6:49 pm on Apr 18, 2015 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15936
votes: 889


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.
8:31 am on Apr 20, 2015 (gmt 0)

New User

joined:Apr 18, 2015
posts: 1
votes: 0


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.
3:43 pm on Apr 20, 2015 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15936
votes: 889


Yes, but do they all come with the text string "This is info" or "This is warn"?
7:04 pm on Apr 21, 2015 (gmt 0)

New User

joined:Mar 20, 2015
posts: 8
votes: 0


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)
12:39 am on Apr 22, 2015 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11873
votes: 245


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.