【问题标题】:How can I remove the socket.io polling logs from my NodeJS app on heroku?如何从 Heroku 上的 NodeJS 应用程序中删除 socket.io 轮询日志?
【发布时间】:2015-08-08 17:39:23
【问题描述】:

Heroku 不支持 websockets,所以在使用 socket.io 时,我的日志已经被/socket.io/ 行变得超级混乱。我怎样才能让它们消失?

2015-05-26T20:57:50.842359+00:00 heroku[router]: at=info method=POST path="/someUsername/today/update" host=complice.co request_id=48483d1f-5389-4dc9-a7e2-0dd975e4cdaf fwd="132.205.236.27" dyno=web.1 connect=2ms service=57ms status=200 bytes=366
2015-05-26T20:57:50.846807+00:00 app[web.1]: 10.69.24.23 - - [26/May/    2015:20:57:50 +0000] "POST /someUsername/today/update HTTP/1.1" 200 17
2015-05-26T20:57:52.471715+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=2&transport=websocket&sid=sLY-oQMlHNsorbKEAAAh" host=complice.co request_id=8c937877-e06f-4503-b8af-a83a070d6aa0 fwd="184.175.46.182" dyno=web.1 connect=1ms service=2125530ms status=101 bytes=504
2015-05-26T20:58:00.584527+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=2&transport=websocket&sid=pBl47HfKOimvv1V6AAAK" host=complice.co request_id=753f792d-e713-4086-901b-23727ee84a5e fwd="184.175.46.182" dyno=web.1 connect=1ms service=2136303ms status=101 bytes=636
2015-05-26T20:58:05.233626+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=2&transport=websocket&sid=RekQs6Jh__ASc7GXAAAT" host=complice.co request_id=17c7ff23-d37f-4fdd-b944-9691c3d717f0 fwd="184.175.46.182" dyno=web.1 connect=5ms service=2140156ms status=101 bytes=577
2015-05-26T20:57:49.144350+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=2&transport=websocket&sid=P9rDPW9bvnvd18knAAA1" host=complice.co request_id=7157af69-a10a-45a1-859d-8e122256a1f8 fwd="184.175.46.182" dyno=web.1 connect=0ms service=2120661ms status=101 bytes=498
2015-05-26T20:58:05.911121+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=2&transport=websocket&sid=eUp5HE_WfsRMwEO6AAAp" host=complice.co request_id=1bc08b67-9574-4c3b-a69f-1e2272953c82 fwd="184.175.46.182" dyno=web.1 connect=0ms service=2138245ms status=101 bytes=640

【问题讨论】:

    标签: node.js sockets logging heroku


    【解决方案1】:

    最快和最简单的方法是: heroku logs -t | grep -v socket.io.

    您可以使用日志库或服务做一些更有趣的事情,但是使用默认的 heroku 日志记录,您会受到限制,因为这些是实际的 GET 请求。我的意思是你不能用应用程序代码来抑制这些。据我所知,您只能使用 heroku 的默认日志按源或进程进行过滤。

    【讨论】:

    • 嗯,有没有办法使用grep -v 不会破坏原木原本拥有的漂亮颜色?
    • 中奖命令:unbuffer heroku logs -t | grep -v socket.io
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    • 2016-07-11
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多