Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8200283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:23:29+00:00 2026-06-07T06:23:29+00:00

I typically don’t like to ask directly how to do something without much understanding

  • 0

I typically don’t like to ask directly how to do something without much understanding of what’s going on, but I’m fairly new to rails and I’m having a hard time accomplishing this.

Basically, I need to capture the following information for each request in a single log statement (if possible)

  • Date of log entry
  • Time of log entry
  • HTTP method
  • URL requested
  • Port
  • IP address of requestor
  • User agent of the requestor
  • Referring URL
  • HTTP response code
  • Hostname

    What’s the preferred way of customizing the log format? Is it possible to just modify the existing logs and pass it this information? Or would I need to extend and overwrite the behavior I need?

    I don’t need this to be saved to a different log file or anything, just output to STDOUT on each request.

    Any help with this would be greatly appreciated.

    Thanks!

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-06-07T06:23:31+00:00Added an answer on June 7, 2026 at 6:23 am

      I believe most, if not all, of the info you requested can be found in the request headers and response. Information on how to add that to logs has been answered before, but basically you can use an around_filter in the ApplicationController to log the information you care about form the request headers. For example here’s how you could log the user agent from the request and status code from the response:

      class ApplicationController < ActionController::Base 
        around_filter :global_request_logging
      
        def global_request_logging 
          logger.info "USERAGENT: #{request.headers['HTTP_USER_AGENT']}"
          begin 
            yield 
          ensure 
            logger.info "response_status: #{response.status}"
          end 
        end 
      end
      

      As far as getting the format you want, if you wrap calls you can output whatever format you want. Also, the Rails logger is also very customizable, and a few projects already exist that might suit your needs to replace default logging or as inspiration for how to go about creating a useful format:

      • lograge – replaces default Rails logging with single line, key-value output, but doesn’t yet do request parameters
      • scrolls – More generic contextual, key-value
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    Typically you start a service like this Intent i = new Intent(context,MessageService.class); context.startService(i); but
    I'm setting up a server for a client (something I don't typically do), and
    I love webpy, it's really quite Pythonic but I don't like having to add
    I typically code in VB.NET, but I'm going through a tutorial in C# .NET
    Typically the model for ORM's that I've used goes something like this: Program startup:
    I don't typically play with Cookies, but I wanted to look into this one
    I typically ssh to another computer to do my development, using vim (don't post
    Typically, I've seen people use the class literal like this: Class<Foo> cls = Foo.class;
    Many Windows apps (like Skype or MSN for instance) don't let you start multiple
    I typically have code like this on a form: private void PerformLongRunningOperation() { BackgroundWorker

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.