Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to find output of previous runs in IntelliJ?

Every time I run some program, the output of previous run of some other program seems to be overwritten by the new output. Is there a way to see the output of previously run programs?

like image 663
Core_Dumped Avatar asked Aug 07 '14 08:08

Core_Dumped


People also ask

How do I get run history in IntelliJ?

Shortcut Ctrl+Shift+Semicolon Show activity on this post.

Where can I find IntelliJ Logs?

In the run/debug configuration that will be used for launching the app, click the Logs tab. The Edit Log Files Aliases table displays the list of log files. Specify the log Alias (the name that will be displayed in the tool window tabs) and the path to the log file. You can also specify an Ant pattern for the log path.

How do I view reports in IntelliJ?

on the Test Runner toolbar. If you haven't run any tests yet, and the tool window with the Test Runner toolbar is not available, press Ctrl+Shift+A and type Import Tests from File . In the dialog that opens, select the . xml file with test results and click Open.


2 Answers

There is not. In the Run/Debug configuration, on the log tab, you can turn on the option "Save console output to file". (You can set this under the "Defaults" configuration so that it always there by default. That however only applies to the current project. To set as a default for all future projects as well, from the Welcome screen (i.e. close all projects) go to Configure > Project Defaults > Run Configurations) Unfortunately, that output file is (also) overwritten on each new run. To the best of my knowledge, there is no way to add a timestamp to the file name. You can open a feature request asking they enhance this to retain the last x number of runs or allow a timestamp.

In the meantime, there are two options you can use for a workaround.

Option 1 - Logging Framework

The first option is to use a logging framework. This won't include the start up information or any System.out/err that the console has (unless you use something like sysout-over-slf4j). On the same "Logs" tab in the Run/Debug configuration, you can set to have the log file shown in the console tool window. The nice thing is that IntelliJ IDEA only shows new output for that run. But the output from previous runs is still in the log file (assuming your logger is set up to append and not overwrite on new runs). When specifying the log name, you can use wild characters (to deal with things like a date stamp in the log). It use Ant fileset pattern notation. Click the help button on "Edit Log Files Aliases" dialog for more information. By default, IDEA only shows the latest log, unless you select the "Show all files coverable by pattern" on the "Edit Log Files Aliases".

Option 2 - Use a Script

Another option would be to use the "Save console file output to file" option. Then write an external script or Ant task that moves/renamed that output. (You could make it fancy so it only saves the last x runs, rolling the previous ones names.) Then in the run/debug configuration, use either the "Run External tool" or "Run Ant Target" option in the "Before Launch" section to run your script. (Again, you can set this on the default configurations so it is there automatically.) This way your script will run, renaming the file, before the new output is created and overwrites the old.

like image 181
Javaru Avatar answered Sep 22 '22 17:09

Javaru


In addition to the options mentioned by Javaru, it is possible to tell IntelliJ to save all console outputs til a local file:

Edit Run Configuration -> Logs -> Save console output to file

like image 43
Tormod Haugene Avatar answered Sep 20 '22 17:09

Tormod Haugene