From: GOTOU Yuuzou Date: 2003-08-24T02:34:51+09:00 Subject: Re: Getting html page fields with webrick Hi, In message , `JK ' wrote: > Well, now instead of having the output of results (server side) to > "$stderr" I want to have it in a "log_file". How to initialize the BasicLog > class? Here is a sample code: require 'webrick' logger = WEBrick::Log::new("log_file", WEBrick::Log::DEBUG) accesslog = WEBrick::BasicLog::new("accesslog") referer = WEBrick::BasicLog::new("referer") agent = WEBrick::BasicLog::new("agent") customlog = WEBrick::BasicLog::new("customlog") s = WEBrick::HTTPServer.new( :BindAddress => "0.0.0.0", :Port => 2000, :DocumentRoot => File::join(ENV["HOME"], "public_html"), :Logger => logger, :AccessLog => [ [ accesslog, WEBrick::AccessLog::COMMON_LOG_FORMAT ], [ referer, WEBrick::AccessLog::REFERER_LOG_FORMAT ], [ agent, WEBrick::AccessLog::AGENT_LOG_FORMAT ], [ customlog, "%a %U %T" ] # peeraddr, Request-URI, process time ] ) trap(:INT){ s.shutdown } s.start There are two logging options; :Logger is server's trace log and :AccessLog is an array of access logs. Each entry of :AccessLog includes BasicLog object and logging format string. The specification of format string is a subset of Apache's LogFormat. -- gotoyuzo