You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Julia 0.6 and I'm starting a new project. Since MicroLogging forms the basis of Base logging for Julia 0.7 and beyond, I figure it's best to get familiar with this now.
As a first step I am trying to log to a file. I can't seem to get the following example working.
I don't get any errors, but I also don't get any logs in the logfile.
Any ideas?
Bump.
I've made some progress, namely I can log to a file but I can only see the log entries when the file handle is closed. How can I view the log entries as they arrive (via tail -f logtest.log)?
using MicroLogging
s =open("logtest.log", "a+")
global_logger(SimpleLogger(s))
@info"msg 1"close(s)
Julia is using buffered IO for the logfile. When the IO buffer fills or (as you've discovered) the stream is closed, you'll see a write. If you want to see a write before then, you can use flush:
using MicroLogging
s =open("logtest.log", "a+")
global_logger(SimpleLogger(s))
@info"msg 1"flush(s)
There is also a way in C to set a file to line buffering mode (setlinebuf) so that it will flush after every newline, but I haven't found any equivalent in Julia.
Hi there,
I'm using Julia 0.6 and I'm starting a new project. Since
MicroLogging
forms the basis of Base logging for Julia 0.7 and beyond, I figure it's best to get familiar with this now.As a first step I am trying to log to a file. I can't seem to get the following example working.
I don't get any errors, but I also don't get any logs in the logfile.
Any ideas?
The text was updated successfully, but these errors were encountered: