I want to write my console application's logs to dynamically specified file. Problem is, even when I run my app like this:
mvn exec:java > /log/app/app.log
all log4j output still gets printed to the screen! Only thing that goes to file is output from standard java printers (print(), println() and so on).
I've read some tutorials about .properties file of log4j, but:
- I couldn't find a way to make file path dynamic, like in example above.
- I have mixed output: some comes from
log4j, some comes from standardprintln();Refactoring might be an issue.
Of course I could find a way to pass target log4j file in execution parameter, but that's not the point - I would end up with two files - one form log4j, and one from rest of the output (println();).
My best option is to find a way to (somehow) catch everything that my app outputs (no matter which way) and put it into file. Best option - bash style.