www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Vibe.D - log requests and responses

reply Saurabh Das <saurabh.das gmail.com> writes:
Hi,

Is there an easy way to log all incoming requests and outgoing 
responses (and perhaps processing time, wait time, etc) in Vibe.D?

Thanks,
Saurabh
Nov 23 2016
parent reply Jacob Carlborg <doob me.com> writes:
On 2016-11-24 07:29, Saurabh Das wrote:
 Hi,

 Is there an easy way to log all incoming requests and outgoing responses
 (and perhaps processing time, wait time, etc) in Vibe.D?
Yes. You can configure the logging on the HTTPServerSettings [1] instance. If you look at the documentation, the first four fields are related to logging. Use "accessLogFile" to set the filename of the log file. Use "accessLogFormat" to configure the log format. It uses the same syntax as Apache. Unfortunately the syntax is not documented in vibe.d and it doesn't implement all of the features that Apache has. I looked at the source code to figure out the format [2]. %D will give you the time taken to serve the request in milliseconds and %T in seconds. %t will give you the time stamp the request was received. I don't see anything related to waiting time. With the "accessLogger" field you can specify a custom logger. [1] http://vibed.org/api/vibe.http.server/HTTPServerSettings [2] https://github.com/rejectedsoftware/vibe.d/blob/master/http/vibe/http/log.d#L92 -- /Jacob Carlborg
Nov 23 2016
parent Saurabh Das <saurabh.das gmail.com> writes:
On Thursday, 24 November 2016 at 07:57:47 UTC, Jacob Carlborg 
wrote:
 On 2016-11-24 07:29, Saurabh Das wrote:
 [...]
Yes. You can configure the logging on the HTTPServerSettings [1] instance. If you look at the documentation, the first four fields are related to logging. Use "accessLogFile" to set the filename of the log file. Use "accessLogFormat" to configure the log format. It uses the same syntax as Apache. Unfortunately the syntax is not documented in vibe.d and it doesn't implement all of the features that Apache has. I looked at the source code to figure out the format [2]. %D will give you the time taken to serve the request in milliseconds and %T in seconds. %t will give you the time stamp the request was received. I don't see anything related to waiting time. [...]
Thanks Jacob. That is precisely what I needed. :)
Nov 24 2016