Hanami: Can't stream log to file

Created on 18 Mar 2016  Â·  6Comments  Â·  Source: hanami/hanami

I am trying to config the log to file with the guide from

https://github.com/hanami/hanami/blob/master/lib/hanami/configuration.rb#L1661

module Api
  class Application < Hanami::Application
    configure do
      ….

      ##
      # LOGGER
      #

      logger.stream "../log/#{Hanami.env}.log"

When I run hanami console, I got the error:

in `block in <class:Application>': undefined method `stream' for nil:NilClass (NoMethodError)

I tried to disable the logger customization above, and inspect the logger instance in console, here is the output:

> Api::Application.configuration.logger.stream
NoMethodError: undefined method `stream' for #<Hanami::Logger:0x007f8b4894a158>

Api::Application.configuration.logger.class
=> Hanami::Logger

Seems like a bug.

invalid

Most helpful comment

@wendy0402 the log currently goes to STDOUT, you could pipe STDOUT to a file when starting your server

All 6 comments

@duykhoa Hello, which version of Hanami are you using? This feature isn't released yet in stable gem. It will be with v0.8.0.

@duykhoa with 0.7.2, there is a bug with the logic of Hanami::Configuration#logger 0.8.0 fixed it as of https://github.com/hanami/hanami/commits/master/lib/hanami/configuration.rb~~

@jodosha i am pairing with @duykhoa. yes it is feature 0.8.0 that he wants to use on 0.7.2, I am closing it now

@joneslee85 Thanks for letting me know :+1:

Hi guys, this is an awesome feature, I've hard time to stream the log into file. Is there any workaround for this?

@wendy0402 the log currently goes to STDOUT, you could pipe STDOUT to a file when starting your server

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bewitchingme picture bewitchingme  Â·  9Comments

zavan picture zavan  Â·  8Comments

gerrywastaken picture gerrywastaken  Â·  3Comments

mkarganov picture mkarganov  Â·  3Comments

cllns picture cllns  Â·  4Comments