Writing to Console on mac OS X

RGK blank at empty.blank
Tue Mar 31 14:46:14 EDT 2009


Thanks for the pointer Irmen. That works fine.

Also my unfamiliarity with the console app is showing - I just learned 
that there is a navigation pane activated by the 'logs' icon that allows 
me to see various system logs, including the Apache ones :p

You're right, I've heard a bit about the Python logging module, but 
never looked into it. This is a good reason to take a look.

Thanks again & Regards,
Ross.

Irmen de Jong wrote:
> RGK wrote:
>> I'm on mac os x 10.4.11 running python 2.5.2, and Django 1.0, but this 
>> is a python question.
>>
>> When doing django/mod_python stuff, I can write to the Apache 
>> error_log file with
>>
>>     sys.stderr.write("SOMETHING I WANT TO KNOW")
>>
>> which had me wondering if there's not a means for a misc. python 
>> program to write to the Mac OS X console?   That would be much nicer 
>> than having to open up the error log and inspect stuff, as then I 
>> could see debug info stream past on a console window.
>>
>> (This is console, as in the "console" run from 
>> /Applications/Utilities, not the bash "Terminal")
>>
>> Any help or suggestions appreciated. Thx.
>>
>> Ross.
> 
> Yeah, use the syslog facility, for instance:
> 
> import syslog
> syslog.openlog("django")
> syslog.syslog(syslog.LOG_ALERT, "Here is my syslog alert message")
> 
> 
> It seems that anything below alert level isn't shown in the console.
> I don't how to change this.
> 
> 
> You might want to consider using the Python logging module instead?
> 
> --irmen



More information about the Python-list mailing list