JavaFx logging example


I am using JavaFx with native packaging. What is the best way to log the System console output to file? Is it possible to use sl4j-simple? Could you please give example?

2/5/2013 6:41:38 AM

Accepted Answer

The simplest way is probably to use the java.util.logging framework and route it's output to a file by following: How to get java Logger output to file by default. Then you don't need to bother with packaging any extra dependencies for logging frameworks. If you do this, you have to use the java.util.logging api, which is slightly awkward compared to slf4j, but it's still workable.

You could certainly use slf4j as your interface instead, but you will need to package extra jar files with your application to accomplish that. If you know maven, then perhaps the easiest way package the libraries would be to build your project using the zenjava maven plugin with appropriate dependencies placed in your project pom for the slf4j logging libraries you would like to use. (I have not used the zenjava maven tool myself though).

5/23/2017 12:32:11 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow