From: Chuck Remes Date: 2008-08-05T04:43:27+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? I hate to resurrect this thread, but I have a problem that I can't seem to solve and I didn't want to rehash the original suggestions. I need a global Logger within a framework I wrote. The trouble is that I need to be able to instantiate multiple independent copies of this framework within the same Ruby runtime (specifically Jruby). If I do this it doesn't work for more than one instance: module Namespace Logger = # instantiate some logger module Submodule class Klass def foo Logger.log("in Klass#foo") end end end end I can load and instantiate this only once in the runtime. If I try to do it a second time, it's like I have reopened the class/module and Logger gets redefined. Each instantiation shares the same global Logger which is *not* what I want. I want each one to have their own instance. Is this possible? Any recommendations for solving it? cr