- Log to STDERR, but redirect STDERR/STDOUT according to the log

settings.
This commit is contained in:
Jordan Sissel 2010-12-22 17:18:19 -08:00
parent a4a4490baf
commit 71ce64cf16
2 changed files with 18 additions and 2 deletions

View file

@ -68,8 +68,19 @@ if settings.daemonize
end
end
agent = LogStash::Agent.new(config)
if settings.logfile
agent.log_to(settings.logfile)
logfile = File.open(settings.logfile, "w")
STDOUT.reopen(logfile)
STDERR.reopen(logfile)
elsif settings.daemonize
# Write to /dev/null if
devnull = File.open("/dev/null", "w")
STDOUT.reopen(devnull)
STDERR.reopen(devnull)
end
agent = LogStash::Agent.new(config)
#if settings.logfile
#agent.log_to(settings.logfile)
#end
agent.run

View file

@ -133,6 +133,11 @@ if settings.logfile
logfile = File.open(settings.logfile, "w")
STDOUT.reopen(logfile)
STDERR.reopen(logfile)
elsif settings.daemonize
# Write to /dev/null if
devnull = File.open("/dev/null", "w")
STDOUT.reopen(devnull)
STDERR.reopen(devnull)
end
Rack::Handler::Thin.run(