I would like the user to be able to choose where the error logs in my application are sent to. I am using tinylog at the moment.
I have used their example code to configure where errors are written to (the user preference is chosen via a Swing fileChooser).
Their example is:
Configurator.defaultConfig() .writer(new FileWriter("log.txt")) .level(Level.WARNING) .activate();
which I have changed to:
Writer fwError= new FileWriter(userPrefs.get("PathForError", null),true); Configurator.defaultConfig().writer(fwError).level(Level.WARNING).activate();
However I get the error as follows "Type mismatch: cannot convert from FileWriter to Writer".
How can I make this conversion work and why doesn’t the example work?
Advertisement
Answer
org.pmw.tinylog.writers.Writer is not ancestor of java.io.FileWriter. try to use full qualified org.pmw.tinylog.writers.FileWriter()