Ruby/Rails Logger

Is there any way to override Logger in order to save logs to database.,
I know how to put results to file or to console/stdout, however I
haven’t found any information how to store logs to database., in my case
I need put logs only to DB, and I don’t need put logs to stdout and
files.

In my understanding I need override Logger to add logic which will
responsible for DB operation, then replace standard Rails logger in
config

config.logger = MyDBLogger.new

However I don’t know how to override/create Logger which will work with
Rails.

I tried, like so

class MyDBLogger < Logger
def initialize(*args)
end

def add(*args)
# save to db
end
end

However in add method I don’t see all comments which exists in console.

Thanks in advance.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs