SysLogHandler is drivin me nuts

M

michael

Hi there,

I am stuck while trying to use the logging facilities. Its not logging
:) Can somebody point me to a solution ?

The following snipplets are used

-------------------------------------------
"crap.py"

logging.config.fileConfig("logging.cfg")
logger = logging.getLogger ("syslog")
logger.info('While this is just chatty')

-------------------------------------------
"logging.cfg"

[syslog]
class=handlers.SysLogHandler
level=ERROR
formatters=form01
facility=LOG_LOCAL0
priority = LOG_INFO

[formatters]
keys=form01

[formatter_form01]
format=%(levelname)s %(message)s

-------------------------------------------
"/etc/syslog.conf"

local0.*;local0.!=debug /var/log/local.log
local0.=debug /var/log/local-d.log

Kind regards

Michael
 
R

roderik

michael said:
Hi there,

I am stuck while trying to use the logging facilities. Its not logging
:) Can somebody point me to a solution ?

The following snipplets are used

-------------------------------------------
"crap.py"

logging.config.fileConfig("logging.cfg")
logger = logging.getLogger ("syslog")
logger.info('While this is just chatty')

-------------------------------------------
"logging.cfg"

[syslog]
class=handlers.SysLogHandler
level=ERROR
formatters=form01
facility=LOG_LOCAL0
priority = LOG_INFO

[formatters]
keys=form01

[formatter_form01]
format=%(levelname)s %(message)s

-------------------------------------------
"/etc/syslog.conf"

local0.*;local0.!=debug /var/log/local.log
local0.=debug /var/log/local-d.log

Kind regards

Michael

I'm taking a wild guess here(io. I haven't tested your code), but I
don't think you can expect a logger of level ERROR to logg messages of
level INFO. Try setting your log level to INFO.

regards
/rune
 
V

Vinay Sajip

michael said:
Hi there,

I am stuck while trying to use the logging facilities. Its not logging
:) Can somebody point me to a solution ?

The following snipplets are used

-------------------------------------------
"crap.py"

logging.config.fileConfig("logging.cfg")
logger = logging.getLogger ("syslog")
logger.info('While this is just chatty')

-------------------------------------------
"logging.cfg"

[syslog]
class=handlers.SysLogHandler
level=ERROR
formatters=form01
facility=LOG_LOCAL0
priority = LOG_INFO

[formatters]
keys=form01

[formatter_form01]
format=%(levelname)s %(message)s

-------------------------------------------
"/etc/syslog.conf"

local0.*;local0.!=debug /var/log/local.log
local0.=debug /var/log/local-d.log

The config file appears incomplete - can you post the whole of it (if
it's not too big)? I would have expected to see lines like

[loggers]
keys=root

[handlers]
keys=syslog

[logger_root]
level=DEBUG
qualname=(root)
handlers=syslog

[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
formatter=form01
host=localhost
port=handlers.SYSLOG_UDP_PORT
facility=LOG_LOCAL0
args=(('localhost', handlers.SYSLOG_UDP_PORT),
handlers.SysLogHandler.LOG_LOCAL0)

(the args line may wrap in this mail)

You can't encode the priority in the config file - it is automatically
determined from the logging level (e.g. INFO -> LOG_INFO).

Note that the SysLogHandler communicates with the syslog daemon via UDP
and there may be network problems preventing the messages getting to the
server. If in doubt, format a UDP packet and send directly from a Python
script (i.e. not via logging) to confirm that there is no network problem.

Best regards,


Vinay Sajip
 
M

michael

Vinay Sajip said:
The config file appears incomplete - can you post the whole of it (if
it's not too big)? I would have expected to see lines like

Yep it was incomplete heres the complete config as it has to be

[loggers]
keys=root,syslog

[handlers]
keys=syslog,file,stdout

[logger_syslog]
qualname=syslog
level=INFO
handlers=syslog

[logger_root]
qualname=root
level=INFO
handlers=stdout

[handler_syslog]
class=handlers.SysLogHandler
level=ERROR
formatter=syslog
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)

[handler_stdout]
class=StreamHandler
level=INFO
formatter=stdout
args=(sys.stdout,)

[handler_file]
class=FileHandler
level=INFO
formatter=stdout
args=('python.log', 'w')

[formatters]
keys=syslog,stdout

[formatter_syslog]
format=%(module)s %(levelname)s %(message)s

[formatter_stdout]
format=%(module)s %(asctime)s %(levelname)s %(message)s

Thanks for the help

Michael
 
V

Vinay Sajip

michael said:
Yep it was incomplete heres the complete config as it has to be
[config file snipped]

The complete file looks OK. Did you take into account the comment
roderik made (about levels - does it work if you set the logger and
handler levels both to DEBUG)? And have you checked that there is no
network problem?

Best regards,

Vinay Sajip
 
M

michael

Vinay Sajip said:
michael said:
Yep it was incomplete heres the complete config as it has to be
[config file snipped]

The complete file looks OK.

Thx. with this file it is working. The syslogd configuration under AIX was buggy.

regards

Michael
 
J

Jan Dries

Slightly OT, but regarding the title, shouldn't it be PEBKAC, since it's
keyboard and not ceyboard?

Regards,
Jan

Vinay Sajip said:
michael said:
Yep it was incomplete heres the complete config as it has to be

[config file snipped]

The complete file looks OK.


Thx. with this file it is working. The syslogd configuration under AIX was buggy.

regards

Michael
 
L

Lloyd Zusman

Jan Dries said:
Slightly OT, but regarding the title, shouldn't it be PEBKAC, since it's
keyboard and not ceyboard?

Your computer didn't come with a ceyboard? :)
 
V

Vinay Sajip

Jan Dries said:
Slightly OT, but regarding the title, shouldn't it be PEBKAC, since it's
keyboard and not ceyboard?

PEBCAC: Problem Exists Between Chair And Computer
 
J

Jan Dries

[Jan Dries]
Slightly OT, but regarding the title, shouldn't it be PEBKAC,
since it's
keyboard and not ceyboard?

[Vinay Sajip]
PEBCAC: Problem Exists Between Chair And Computer

Interesting. I thought it was "Problem Exists Between Keyboard And Chair".
But this makes sensee too, of course. Nonetheless, Google has about 17000
references for PEBKAC, and only 381 for PEBCAC.

Regards,
Jan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top