Search code examples
javalog4jreal-time

Log4J - Auto refresh log files, is it possible?


I've started to make tests, and all the output is sent to a ".log" file. In one test, I have to stop manually the application in a certain line of log.

The question is: Can a .log file work like a Console, displaying info in real time?


Solution

  • You can monitor a log file with tail -f https://en.wikipedia.org/wiki/Tail_%28Unix%29

    Within your java code you can monitor its output see java runtime.getruntime() getting output from executing a command line program

    or create your own appender How to create a own Appender in log4j?