Gary Bernhardt wrote:
> On Wed, Jul 23, 2008 at 2:03 PM, Michael Bayer <[EMAIL PROTECTED]> wrote:
>> the .ini file in use has that exact logging configuration already.   paster
>> with the "--daemon" option redirects stdout and stderr to paster.log.
>>
>> Here is the source code from PasteScript's "script.py" which does this:
>>
>>  if getattr(self.options, 'daemon', False):
>>            if not self.options.pid_file:
>>                self.options.pid_file = 'paster.pid'
>>            if not self.options.log_file:
>>                self.options.log_file = 'paster.log'
>>
>> and later....
>>
>>        if self.options.log_file:
>>            stdout_log = LazyWriter(self.options.log_file, 'a')
>>            sys.stdout = stdout_log
>>            sys.stderr = stdout_log
>>            logging.basicConfig(stream=stdout_log)
>>
>> There's no conditional behavior within --daemon mode or consultation of
>> existing log configurations ("logging" in fact does not provide this
>> capability, as we would love to have it in SQLA).  If --daemon is set,
>> stdout/stderr are going to a plain file.
> 
> Indeed. My mistake.
> 
> I cooked up a patch to allow "--log-file -". However, my experience
> with daemonization is limited, so I'm not so confident in it. Most
> notably, it doesn't close *any* files when the log file is "-", which
> may be the wrong thing to do. I wouldn't recommend using it unless you
> know enough about daemonization to judge it correct. ;)
> 
> It does seem to work, however, so far as I can see. Paste's startup
> messages, log entries, and exceptions all come out correctly when you
> do "paster [args] --log-file - > foo.log". Although, if the server is
> running SSL and you break protocol (e.g. by trying to talk un-SSLed
> HTTP), that exception won't show up in the log. I can't say I have the
> slightest idea why; it should be going to sys.stderr just like any
> other.

--log-file=- seems like a reasonable solution to me.  Supporting 
something like --log-file="|rotate..." seems complicated in comparison.

My knowledge of daemonization is a bit vague in places too, but I think 
stdout will be shared between the parent process and the daemon fork.

paster serve clones stderr to stdout if you use --log-file, but maybe 
your patch does that differently or wrong in some fashion.  And probably 
it shouldn't clone anything in that case.  So you'd have to do:

   paster serve config.ini --daemon --log-file=- 2>&1 | rotate-logs

Or maybe 2>&1 should go after | rotate-logs?  That has always confused me.

-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to