Rails: Log stuff to rails app logs from any ruby class -


I want to be able to log in to my Rails app logs from Ruby Class.

I was hoping to do a class with logger.info "some stuff" in my_app / app / myClass.rb , but it It is not defined when I use logger in my controllers and elsewhere then it works

I'm brand new to Rail / Ruby, and I'm assuming it That is because logger category myClass.rb , but it is automatically included in all controllers, models, etc.

How can I include the logger class in an arbitrary Ruby class, or else I can login to my Rail App from a Ruby Class?

"Post-Text "Itemprop =" text ">

If you want to create your own logger:

  class MyClass def initialize @app_logger = Logger.new (" # {Rails.root} / log /app.log ") End DEF Other Method @ app_logger.info (" Anything here ") End / <>    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -