0

Code:

from pyngrok import ngrok

public_url = ngrok.connect(
    log_stdout=True, log_file="ngrok.log", log_format="json", log_level="debug", proto="tcp", addr="8080"
)
print(public_url)
while True:
    pass

I found this on the internet but it aint working, well its starting the server but its not logging anything, how do i make it log things?

thanks

  • Curious where you found this. `pyngrok`'s `connect()` does take `kwargs`, but I'm not sure passing those `log_` args would actually do anything, and in fact `pyngrok` cannot log to a file, as the wrapper relies on console log output for its own execution. Might I suggest using the `log_event_callback` instead? I think that could possibly work for what you're trying to do, and it's documented [here](https://pyngrok.readthedocs.io/en/latest/index.html#event-logs). – alexdlaird Dec 23 '22 at 17:28

1 Answers1

0

I'm not familiar with that approach but in general, you probably want to do it a little bit differently. Check out the local ngrok API - https://ngrok.com/docs/ngrok-agent/api#list-captured-requests - which will let you capture all the requests in JSON for logging, replay, or whatever.

~ an ngrok employee

CaseySoftware
  • 3,105
  • 20
  • 18