31

Is there a way to tell IntelliJ where to store the output info?

Line
  • 1,529
  • 3
  • 18
  • 42
Leonardo Eras
  • 313
  • 1
  • 3
  • 5
  • Are you making an IntelliJ plugin? And you know how to store the output, but just need to get a project path? Why don't you just use a logback? – Meo Sep 25 '17 at 20:22
  • The plugin will be used by students in the laboratory. After project loading, they are requested their student ID, so a new folder can be created for student. There I want to save the console output of whatever they are programming in IntelliJ. – Leonardo Eras Sep 29 '17 at 17:32
  • Does this answer your question? [Is it possible to redirect console output to a log file in IntelliJ like Eclipse?](https://stackoverflow.com/questions/4736020/is-it-possible-to-redirect-console-output-to-a-log-file-in-intellij-like-eclipse) – Line Sep 28 '22 at 15:35

4 Answers4

42
  1. Go to Run/Debug Configuration
  2. Click the "Logs" tab
  3. Check the "Save console output to file" box and select the output directory.
  4. Apply/OK

Source: https://www.jetbrains.com/help/idea/setting-log-options.html

Strikegently
  • 2,251
  • 20
  • 23
  • 1
    Is there a way to change it programming? I'm not going to use the plugin, some students are, and I don't know about their machines, I just want it to be saved in the same path as their projects – Leonardo Eras Sep 25 '17 at 17:17
  • > https://github.com/JetBrains/intellij-community/tree/master/platform/lang-impl/src/com/intellij/diagnostic/logging – Meo Sep 25 '17 at 20:28
  • 4
    It didn't work, through server console in intellij game message that "console output is saving to = (folder name) but still its not creating log file. Am i missing something? – Kushwaha Sep 02 '21 at 10:41
  • is is possible to make IDEA automatically rotate this file, say, after every run? – Yar Nov 03 '21 at 15:28
  • @Kushwaha You need to save the run configuration. If it is not saved is greyed out. It should be left to the run button (containing your script name). Click on your script name and select save in the dropdown menu. – Sašo Pavlič Jul 17 '22 at 14:03
7

Official UPDATE from IntelliJ help page:
For the New appearance

Save console output to a file
If you use console output for logging, you can save it to a file for later inspection.

  1. In the run/debug configuration that will be used for launching the app, click Modify options. From the menu, select Save console output to file.

  2. Specify the path to the file. If the file does not exist, it will be created automatically upon the first write.

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
7

In newer IntelliJ editions, starting with ~ year 2020, the setting has again visually moved. In addition to answer from @ahmednabil88:

In Run/Debug Configurations dialog: add Modify options > Logs > Save console output to file:

Screenshot of how to add log filie in "Run Configuration" parameters

Then enter the path and file name, e.g. with IntelliJ 2022.2.5: Example of log file

t0r0X
  • 4,212
  • 1
  • 38
  • 34
  • 1
    followed the instructions, but the file does not get created or written to – Tim Boland May 25 '23 at 21:33
  • @TimBoland I just tested this with IntelliJ 2022.2.5 and it worked. Have you supplied a filename with path? I'll add another screenshot illustrating my configuration. – t0r0X Jun 13 '23 at 20:36
1

Please note that at some point in 2018, this feature stopped working properly in IntelliJ for a number of users. As earlier answers to this question have indicated, IntelliJ's own documentation shows that it should be possible to write logs to a file.

There was a bug report filed with IntelliJ in 2018 that has still not been fixed. If you really need this feature, vote for it here to increase the chances that it gets fixed: https://youtrack.jetbrains.com/issue/IDEA-194934

drapkin11
  • 1,205
  • 2
  • 12
  • 24