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 8579319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:35:13+00:00 2026-06-11T20:35:13+00:00

This is a ruby script which i am using to log my status. require

  • 0

This is a ruby script which i am using to log my status.

require 'logger'

log = Logger.new( 'log.txt', 'daily' )

log.debug "Once the log becomes at least one"
log.debug "day old, it will be renamed and a"
log.debug "new log.txt file will be created."

Now i want to make a new ruby file in which i want to include logger it can be like this

module Logging

  def logger
    Logging.logger
  end

  def self.logger
    @logger ||= Logger.new(STDOUT)
  end

end

But i am not able to understand this so can anyone explain it.

my requirement is like there are lots of ruby script file i want to put a logger in module and include that in every file than write log in log file it can be warning it can be a info or anything else.

  • 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-11T20:35:14+00:00Added an answer on June 11, 2026 at 8:35 pm

    A better alternative would be:

    module Logging
    
    def logger
    @logger ||= Logger.new(STDOUT)
    end
    
    end
    

    And use it like this

    class MyLoggingClient
    include Logging
    
    #Now you have access to the method `logger` and the instance variable `@logger`.
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well. I'm trying to write simple scheduler in ruby, just simple script which once
I am trying to install ruby 1.9.2 from a ruby script using rvm which
I have a ruby script which I run using the JRuby Interpreter. The script
I have this ruby script that allows me to enter the name of a
I get this error when trying ruby script/console Rails requires RubyGems >= . Please
I am following this tutorial and I've run the command ruby script\server and successfully
On windows, I can run my ruby script like this: > ruby myscript.rb but
I'm writing a ruby bootstrapping script for a school project, and part of this
I'm trying to publish messages to RabbitMQ, from a Ruby script (using Bunny )
I'm looking to write a Ruby script which I can load into the Rails

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.