Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFx logging example

Tags:

logging

javafx

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?

like image 416
Freelander Avatar asked Nov 04 '22 05:11

Freelander


1 Answers

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).

like image 104
jewelsea Avatar answered Nov 08 '22 14:11

jewelsea