- Defined in:
A bucket can be set to log the requests made on it. By default logging is turned off. You can check if a bucket has logging enabled:
.logging_enabled_for? 'jukebox' # => false
Enabling it is easy:
Unless you specify otherwise, logs will be written to the bucket you want
to log. The logs are just like any other object. By default they will start
with the prefix 'log-'. You can customize what bucket you want the
logs to be delivered to, as well as customize what the log objects' key
is prefixed with by setting the
.enable_logging_for( 'jukebox', 'target_bucket' => 'jukebox-logs' )
Now instead of logging right into the jukebox bucket, the logs will go into the bucket called jukebox-logs.
Once logs have accumulated, you can access them using the
pp Bucket.logs('jukebox') [#<AWS::S3::Logging::Log '/jukebox-logs/log-2006-11-14-07-15-24-2061C35880A310A1'>, #<AWS::S3::Logging::Log '/jukebox-logs/log-2006-11-14-08-15-27-D8EEF536EC09E6B3'>, #<AWS::S3::Logging::Log '/jukebox-logs/log-2006-11-14-08-15-29-355812B2B15BD789'>]
Each log has a
lines method that gives you information about
each request in that log. All the fields are available as named methods.
More information is available in Logging::Log::Line.
logs = .logs('jukebox') log = logs.first line = log.lines.first line.operation # => 'REST.GET.LOGGING_STATUS' line.request_uri # => 'GET /jukebox?logging HTTP/1.1' line.remote_ip # => "220.127.116.11"
Disabling logging is just as simple as enabling it:
Defined Under Namespace