lines change places in logfile










0















I use the logstasher gem to convert my logs into json objects
then I add a line before each log line,
in development everything works fine.
In production sometimes the lines change places.



this is how it should be



"index":"_id":"3cc6221b633bd2bd0a95865e9c0c3dfd"
"method":"GET","path":"/public/so_list","format":"*/*","controller":"public","action":"so_list","status":200,"duration":3152.27,"view":246.58,"db":2882.97,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
"index":"_id":"4b94f72318d88a8d7c1c5e46e5465246"
"method":"GET","path":"/public/ajx_group_items/DY2149","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":118.89,"view":31.89,"db":74.0,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
"index":"_id":"b1ceb09e59379be7e26bff6b0d91ccd9"
"method":"GET","path":"/public/login","format":"html","controller":"public","action":"login","status":200,"duration":44.24,"view":41.55,"db":1.25,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"


and sometimes happens this



line 2 should change places with line 3



"index":"_id":"f6ee3d21d6e424652cdca28e9fdff611"
"index":"_id":"3c5050daede3f29d0402e888eef02046"
"method":"GET","path":"/public/ajx_group_items/DY7100","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":341.08,"view":169.3,"db":157.56,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
"method":"GET","path":"/public/ajx_group_items/DY7000","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":334.34,"view":191.42,"db":129.59,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
"index":"_id":"f6f59814f6cd45851d529a4efd1d5989"
"method":"GET","path":"/public/ajx_group_items/DY7210","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":305.02,"view":221.0,"db":72.51,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"


my initializer looks like that



if LogStasher.enabled?

LogStasher::ActiveSupport::LogSubscriber.class_eval do

alias :original_process_action :process_action

def process_action(event)

# this creates the first line before each log
log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
hash = index: _id: event.payload[:request_id]
log_extra_line.info(hash.to_json)

# this adds the log line
original_process_action(event)
end

end

end


then I changed the initializer to this
assuming that if i pass both arg to an function and then do the logs it works, but i have still the same problem.



if LogStasher.enabled?

LogStasher::ActiveSupport::LogSubscriber.class_eval do

alias :original_process_action :process_action

def process_action(event)
hash = index: _id: event.payload[:request_id]
do_logs(hash, event)
end

def do_logs(elastic_hash, original_log)
# this creates the first line before each log
log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
log_extra_line.info(elastic_hash.to_json)
# this adds the log line
original_process_action(original_log)
end

end

end


What i am doing wrong?










share|improve this question




























    0















    I use the logstasher gem to convert my logs into json objects
    then I add a line before each log line,
    in development everything works fine.
    In production sometimes the lines change places.



    this is how it should be



    "index":"_id":"3cc6221b633bd2bd0a95865e9c0c3dfd"
    "method":"GET","path":"/public/so_list","format":"*/*","controller":"public","action":"so_list","status":200,"duration":3152.27,"view":246.58,"db":2882.97,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
    "index":"_id":"4b94f72318d88a8d7c1c5e46e5465246"
    "method":"GET","path":"/public/ajx_group_items/DY2149","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":118.89,"view":31.89,"db":74.0,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
    "index":"_id":"b1ceb09e59379be7e26bff6b0d91ccd9"
    "method":"GET","path":"/public/login","format":"html","controller":"public","action":"login","status":200,"duration":44.24,"view":41.55,"db":1.25,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"


    and sometimes happens this



    line 2 should change places with line 3



    "index":"_id":"f6ee3d21d6e424652cdca28e9fdff611"
    "index":"_id":"3c5050daede3f29d0402e888eef02046"
    "method":"GET","path":"/public/ajx_group_items/DY7100","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":341.08,"view":169.3,"db":157.56,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
    "method":"GET","path":"/public/ajx_group_items/DY7000","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":334.34,"view":191.42,"db":129.59,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
    "index":"_id":"f6f59814f6cd45851d529a4efd1d5989"
    "method":"GET","path":"/public/ajx_group_items/DY7210","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":305.02,"view":221.0,"db":72.51,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"


    my initializer looks like that



    if LogStasher.enabled?

    LogStasher::ActiveSupport::LogSubscriber.class_eval do

    alias :original_process_action :process_action

    def process_action(event)

    # this creates the first line before each log
    log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
    hash = index: _id: event.payload[:request_id]
    log_extra_line.info(hash.to_json)

    # this adds the log line
    original_process_action(event)
    end

    end

    end


    then I changed the initializer to this
    assuming that if i pass both arg to an function and then do the logs it works, but i have still the same problem.



    if LogStasher.enabled?

    LogStasher::ActiveSupport::LogSubscriber.class_eval do

    alias :original_process_action :process_action

    def process_action(event)
    hash = index: _id: event.payload[:request_id]
    do_logs(hash, event)
    end

    def do_logs(elastic_hash, original_log)
    # this creates the first line before each log
    log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
    log_extra_line.info(elastic_hash.to_json)
    # this adds the log line
    original_process_action(original_log)
    end

    end

    end


    What i am doing wrong?










    share|improve this question


























      0












      0








      0








      I use the logstasher gem to convert my logs into json objects
      then I add a line before each log line,
      in development everything works fine.
      In production sometimes the lines change places.



      this is how it should be



      "index":"_id":"3cc6221b633bd2bd0a95865e9c0c3dfd"
      "method":"GET","path":"/public/so_list","format":"*/*","controller":"public","action":"so_list","status":200,"duration":3152.27,"view":246.58,"db":2882.97,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
      "index":"_id":"4b94f72318d88a8d7c1c5e46e5465246"
      "method":"GET","path":"/public/ajx_group_items/DY2149","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":118.89,"view":31.89,"db":74.0,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
      "index":"_id":"b1ceb09e59379be7e26bff6b0d91ccd9"
      "method":"GET","path":"/public/login","format":"html","controller":"public","action":"login","status":200,"duration":44.24,"view":41.55,"db":1.25,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"


      and sometimes happens this



      line 2 should change places with line 3



      "index":"_id":"f6ee3d21d6e424652cdca28e9fdff611"
      "index":"_id":"3c5050daede3f29d0402e888eef02046"
      "method":"GET","path":"/public/ajx_group_items/DY7100","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":341.08,"view":169.3,"db":157.56,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
      "method":"GET","path":"/public/ajx_group_items/DY7000","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":334.34,"view":191.42,"db":129.59,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
      "index":"_id":"f6f59814f6cd45851d529a4efd1d5989"
      "method":"GET","path":"/public/ajx_group_items/DY7210","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":305.02,"view":221.0,"db":72.51,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"


      my initializer looks like that



      if LogStasher.enabled?

      LogStasher::ActiveSupport::LogSubscriber.class_eval do

      alias :original_process_action :process_action

      def process_action(event)

      # this creates the first line before each log
      log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
      hash = index: _id: event.payload[:request_id]
      log_extra_line.info(hash.to_json)

      # this adds the log line
      original_process_action(event)
      end

      end

      end


      then I changed the initializer to this
      assuming that if i pass both arg to an function and then do the logs it works, but i have still the same problem.



      if LogStasher.enabled?

      LogStasher::ActiveSupport::LogSubscriber.class_eval do

      alias :original_process_action :process_action

      def process_action(event)
      hash = index: _id: event.payload[:request_id]
      do_logs(hash, event)
      end

      def do_logs(elastic_hash, original_log)
      # this creates the first line before each log
      log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
      log_extra_line.info(elastic_hash.to_json)
      # this adds the log line
      original_process_action(original_log)
      end

      end

      end


      What i am doing wrong?










      share|improve this question
















      I use the logstasher gem to convert my logs into json objects
      then I add a line before each log line,
      in development everything works fine.
      In production sometimes the lines change places.



      this is how it should be



      "index":"_id":"3cc6221b633bd2bd0a95865e9c0c3dfd"
      "method":"GET","path":"/public/so_list","format":"*/*","controller":"public","action":"so_list","status":200,"duration":3152.27,"view":246.58,"db":2882.97,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
      "index":"_id":"4b94f72318d88a8d7c1c5e46e5465246"
      "method":"GET","path":"/public/ajx_group_items/DY2149","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":118.89,"view":31.89,"db":74.0,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"
      "index":"_id":"b1ceb09e59379be7e26bff6b0d91ccd9"
      "method":"GET","path":"/public/login","format":"html","controller":"public","action":"login","status":200,"duration":44.24,"view":41.55,"db":1.25,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:36Z","@version":"1"


      and sometimes happens this



      line 2 should change places with line 3



      "index":"_id":"f6ee3d21d6e424652cdca28e9fdff611"
      "index":"_id":"3c5050daede3f29d0402e888eef02046"
      "method":"GET","path":"/public/ajx_group_items/DY7100","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":341.08,"view":169.3,"db":157.56,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
      "method":"GET","path":"/public/ajx_group_items/DY7000","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":334.34,"view":191.42,"db":129.59,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"
      "index":"_id":"f6f59814f6cd45851d529a4efd1d5989"
      "method":"GET","path":"/public/ajx_group_items/DY7210","format":"*/*","controller":"public","action":"ajx_group_items","status":200,"duration":305.02,"view":221.0,"db":72.51,"ip":null,"route":null,"request_id":null,"source":"unknown","tags":["request"],"@timestamp":"2018-11-15T18:53:37Z","@version":"1"


      my initializer looks like that



      if LogStasher.enabled?

      LogStasher::ActiveSupport::LogSubscriber.class_eval do

      alias :original_process_action :process_action

      def process_action(event)

      # this creates the first line before each log
      log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
      hash = index: _id: event.payload[:request_id]
      log_extra_line.info(hash.to_json)

      # this adds the log line
      original_process_action(event)
      end

      end

      end


      then I changed the initializer to this
      assuming that if i pass both arg to an function and then do the logs it works, but i have still the same problem.



      if LogStasher.enabled?

      LogStasher::ActiveSupport::LogSubscriber.class_eval do

      alias :original_process_action :process_action

      def process_action(event)
      hash = index: _id: event.payload[:request_id]
      do_logs(hash, event)
      end

      def do_logs(elastic_hash, original_log)
      # this creates the first line before each log
      log_extra_line = Logger.new("#Rails.root/log/logstasher.log")
      log_extra_line.info(elastic_hash.to_json)
      # this adds the log line
      original_process_action(original_log)
      end

      end

      end


      What i am doing wrong?







      ruby-on-rails ruby logging rubygems production






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 15:28







      mat's

















      asked Nov 15 '18 at 19:25









      mat'smat's

      277




      277






















          2 Answers
          2






          active

          oldest

          votes


















          1














          This has to do with your server's concurrency. When run locally, by default Rails servers run a single thread. In production, they are usually multi-threaded. The log lines are coming in out-of-order because they belong to different requests.



          Take a look at the rails docs on threading and concurrency for more info.






          share|improve this answer























          • Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

            – mat's
            Nov 19 '18 at 18:38











          • @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

            – Cara McCormack
            Nov 20 '18 at 15:05











          • what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

            – mat's
            Nov 20 '18 at 16:17



















          1














          In the initializer, in the elastic_hash I added the event.
          The new hash has first the index then the event.
          Then i do



          log = Logger.new("#Rails.root/log/logstasher.log")
          log.info(elastic_hash.to_json)


          with this i create only one line for each log, including index and event
          and it works



          In this case I wouldn't need the gem logsthasher i am sure that it would work different too






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326625%2flines-change-places-in-logfile%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            This has to do with your server's concurrency. When run locally, by default Rails servers run a single thread. In production, they are usually multi-threaded. The log lines are coming in out-of-order because they belong to different requests.



            Take a look at the rails docs on threading and concurrency for more info.






            share|improve this answer























            • Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

              – mat's
              Nov 19 '18 at 18:38











            • @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

              – Cara McCormack
              Nov 20 '18 at 15:05











            • what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

              – mat's
              Nov 20 '18 at 16:17
















            1














            This has to do with your server's concurrency. When run locally, by default Rails servers run a single thread. In production, they are usually multi-threaded. The log lines are coming in out-of-order because they belong to different requests.



            Take a look at the rails docs on threading and concurrency for more info.






            share|improve this answer























            • Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

              – mat's
              Nov 19 '18 at 18:38











            • @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

              – Cara McCormack
              Nov 20 '18 at 15:05











            • what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

              – mat's
              Nov 20 '18 at 16:17














            1












            1








            1







            This has to do with your server's concurrency. When run locally, by default Rails servers run a single thread. In production, they are usually multi-threaded. The log lines are coming in out-of-order because they belong to different requests.



            Take a look at the rails docs on threading and concurrency for more info.






            share|improve this answer













            This has to do with your server's concurrency. When run locally, by default Rails servers run a single thread. In production, they are usually multi-threaded. The log lines are coming in out-of-order because they belong to different requests.



            Take a look at the rails docs on threading and concurrency for more info.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 19 '18 at 16:27









            Cara McCormackCara McCormack

            326518




            326518












            • Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

              – mat's
              Nov 19 '18 at 18:38











            • @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

              – Cara McCormack
              Nov 20 '18 at 15:05











            • what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

              – mat's
              Nov 20 '18 at 16:17


















            • Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

              – mat's
              Nov 19 '18 at 18:38











            • @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

              – Cara McCormack
              Nov 20 '18 at 15:05











            • what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

              – mat's
              Nov 20 '18 at 16:17

















            Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

            – mat's
            Nov 19 '18 at 18:38





            Hi @Cara McCormack i was reading the link, but i still don't know how to solve that

            – mat's
            Nov 19 '18 at 18:38













            @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

            – Cara McCormack
            Nov 20 '18 at 15:05





            @mat's - it depends on what you're actually trying to solve. Log lines not appearing in order is usually expected in multithreaded systems. I'd recommend also logging the request ID and using some sort of log parser if you need to track individual requests through the flow in order. Otherwise, you could run a single-threaded server in production as well, although there will obviously be performance penalties.

            – Cara McCormack
            Nov 20 '18 at 15:05













            what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

            – mat's
            Nov 20 '18 at 16:17






            what i really wanted to do is add before each log a index. and then import the log to elasticsearch. is there a better way to do that ?

            – mat's
            Nov 20 '18 at 16:17














            1














            In the initializer, in the elastic_hash I added the event.
            The new hash has first the index then the event.
            Then i do



            log = Logger.new("#Rails.root/log/logstasher.log")
            log.info(elastic_hash.to_json)


            with this i create only one line for each log, including index and event
            and it works



            In this case I wouldn't need the gem logsthasher i am sure that it would work different too






            share|improve this answer



























              1














              In the initializer, in the elastic_hash I added the event.
              The new hash has first the index then the event.
              Then i do



              log = Logger.new("#Rails.root/log/logstasher.log")
              log.info(elastic_hash.to_json)


              with this i create only one line for each log, including index and event
              and it works



              In this case I wouldn't need the gem logsthasher i am sure that it would work different too






              share|improve this answer

























                1












                1








                1







                In the initializer, in the elastic_hash I added the event.
                The new hash has first the index then the event.
                Then i do



                log = Logger.new("#Rails.root/log/logstasher.log")
                log.info(elastic_hash.to_json)


                with this i create only one line for each log, including index and event
                and it works



                In this case I wouldn't need the gem logsthasher i am sure that it would work different too






                share|improve this answer













                In the initializer, in the elastic_hash I added the event.
                The new hash has first the index then the event.
                Then i do



                log = Logger.new("#Rails.root/log/logstasher.log")
                log.info(elastic_hash.to_json)


                with this i create only one line for each log, including index and event
                and it works



                In this case I wouldn't need the gem logsthasher i am sure that it would work different too







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 27 '18 at 18:49









                mat'smat's

                277




                277



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326625%2flines-change-places-in-logfile%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3