Use rails logger in a class without active record


#1

How do I use the regular rails logger in a rails app in a class that
is does not inherit from active record?


#2

Quoting Me removed_email_address@domain.invalid:

How do I use the regular rails logger in a rails app in a class that
is does not inherit from active record?

RAILS_DEFAULT_LOGGER.debug “Debug message”

HTH,
Jeffrey


#3

Do you want to log from a controller? If so, something like this in
application.rb is handy:

def log(message)
logger.info “Any_prefix_you_want_to_grep: #{message.to_s}”
end

If you want to log from somewhere that’s not inheriting any part of
the rails stack, I’ll let someone else answer…