'How to create config properties for tinylog at runtime with User preferences

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source