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. > LazyWriter only accepts a string filename (uses open(name, 'w') on it). > > So I could just change my .ini file to entirely move logging elsewhere, such > as the RotatingFileHandler, but I was hoping for a single point of > configuration that catches everything, exceptions, print statements, etc., > and is immediately understandable by any sysadmin. > > > On Jul 23, 2008, at 1:34 PM, Gary Bernhardt wrote: > >> Paste will automatically interpret your ini file as a logging module >> config file if the "loggers" key is present. See the "Basic Logging >> Configuration" section at >> <http://wiki.pylonshq.com/display/pylonsdocs/Logging>. The example in >> that section sends all logging to stderr, which seems to be what you >> want, modulo stderr. Last I checked there wasn't any mention of this >> in the Paste docs, but I may have just overlooked it. >> >> On Wed, Jul 23, 2008 at 10:08 AM, Michael Bayer >> <[EMAIL PROTECTED]> wrote: >>> >>> In this case the executable in question is "rotatelogs". Two ways >>> this could be achieved would be: >>> >>> a. if paster supported a "stdout" option for logging. Currently if >>> you dont specify a --log-file option, it goes straight to "paster.log". >>> >>> b. if the --log-file option supported pipes, such as: >>> >>> paster serve --daemon --log-file "| rotatelogs ./logs/mylog.txt >>> 86400" >>> >>> c. im missing something completely obvious ? (very common) >>> >>> _______________________________________________ >>> Paste-users mailing list >>> [email protected] >>> http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users >>> >> >> >> >> -- >> Gary >> http://blog.extracheese.org > > -- Gary http://blog.extracheese.org
allow_logging_to_stdout.diff
Description: Binary data
_______________________________________________ Paste-users mailing list [email protected] http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users
