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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With