Up till now I outputted all required logging information via the most basic command:
System.out.println("Normal logging information"); System.err.println("... when things go wrong information");
This is OK, but gives me little control. Therefore I took a look at the different Java libraries available and came to the conclusion that SLF4J is the one I need. Added the two required libraries (slf4j-api-1.7.22.jar and slf4j-jdk14-1.7.22.jar) to my project and tested rapidly.
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Test { private final static Logger TestLog = LoggerFactory.getLogger(Test.class); public static void main(String s[]) throws Exception { System.out.println("Running tests"); int ret = fsuipc_wrapper.Open(fsuipc_wrapper.SIM_ANY); System.out.println("ret =" + ret); if(ret == 0 ) { TestLog.error("FlightSim not found"); } else { TestLog.info("Connection with P3D established"); } } }
Seems to work!
Ps: Currently I use JDK as implementation (cfr. added libraries) for the actual logging, but this might be changed later on. Lot’s of options there… Take a closer look at https://youtu.be/tMLEbGJ2z7I