# Log REPL text to file

**URL:** <https://discourse.julialang.org/t/log-repl-text-to-file/17761>\
**Category:** General Usage\
**Created:** [November 20, 2018, 7:14am UTC](https://discourse.julialang.org/t/log-repl-text-to-file/17761 "2018-11-20T07:14:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [November 20, 2018, 7:14am UTC](https://discourse.julialang.org/t/log-repl-text-to-file/17761/1 "2018-11-20T07:14:48Z")

</div>

Hi all,  
Is there a simple command to set up text logging of the REPL output?  
Something like MATLAB’s ‘diary’ function: [Log Command Window text to file - MATLAB diary](https://www.mathworks.com/help/matlab/ref/diary.html)  
I always found this useful when running scripts blind on clusters, other wise you end up peppering such scripts with calls to print into a text file.  
Cheers  
Tim

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [November 20, 2018, 8:10am UTC](https://discourse.julialang.org/t/log-repl-text-to-file/17761/2 "2018-11-20T08:10:53Z")

</div>

There are packages like [IOLogging.jl](https://github.com/Seelengrab/IOLogging.jl) for logging different levels to different files, but if you care just about all levels in a single file [this example from the docs](https://docs.julialang.org/en/v1.0.1/stdlib/Logging/#Writing-log-events-to-a-file-1) should work just fine.

Logging all REPL output is not currently possible directly - your best bet is to redirect stdout, but I can’t guarantee that will work.

---

<div class="post-metadata">

**Author:** ![timmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timmm/32/6760_2.png) [@timmm](https://discourse.julialang.org/u/timmm)\
**Post date:** [November 20, 2018, 3:39pm UTC](https://discourse.julialang.org/t/log-repl-text-to-file/17761/3 "2018-11-20T15:39:49Z")

</div>

Thanks, very useful.

I also noticed after a bit more searching (Julia 1.0.2):

In Linux there is a hidden folder:  
ls -ld .?\*  
called “.julia” in my home directory where I have been running Julia from:  
vi .julia/logs/repl\_history.jl

In Windows its at:  
“USERDIR.julia\logs\repl\_history.jl”

These appear to contain the whole REPL history.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [November 20, 2018, 4:08pm UTC](https://discourse.julialang.org/t/log-repl-text-to-file/17761/4 "2018-11-20T16:08:42Z")

</div>

On Unix systems, you used to able to use the `script` command to log all input and output in a console. It’s written to a file called `typescript` by default, and you stop logging using Ctrl-D. However, the big problem is that it records all the ANSI escape sequences as well, making the resulting file virtually unusable for most purposes:

```nohighlight
e[0Ke[32me[1mjulia-1.0> e[0me[0m
e[11C[cos(x) for x in range(0, stop=2π, length=200)]
e[58C
e[?2004le[0me[0m200-element Array{Float64,1}:
 1.0               
 0.9995015891261738
 0.9980068533314934
 0.995517282601106 
 0.9920353585932578
 0.9875645521655237
 0.9821093199149804
 0.9756750997357736
 0.9682683053985072
 0.959896320156857 
 0.9505674893877829
 0.9402911122726756
 0.9290774325277306
 0.9169376281927888
 0.9038838004888236
 0.8899289617551803
 0.8750870224785937
 0.859372777426912 
 0.8428018909013506
 0.8253908811219762
 0.8071571037619854
 0.7881187346471924
 0.7682947516379708
 0.7477049157117092
 0.7263697512646394
 ⋮                 
 0.7477049157117087
 0.7682947516379706
 0.7881187346471925
 0.8071571037619851
 0.8253908811219762
 0.8428018909013504
 0.8593727774269119
 0.8750870224785938
 0.8899289617551801
 0.9038838004888236
 0.9169376281927886
 0.9290774325277305
 0.9402911122726754
 0.9505674893877828
 0.959896320156857 
 0.9682683053985071
 0.9756750997357736
 0.9821093199149803
 0.9875645521655236
 0.9920353585932579
 0.9955172826011058
 0.9980068533314933
 0.9995015891261737
 1.0               
e[0K
e[0Ke[32me[1mjulia-1.0> 
e[0K
e[0Ke[32me[1mjulia-1.0> e

```
