I tried using TinyLog for a sample application to make sure understanding how it works, so that i can use it for my work application.
But, while using i get an exception to type cast the Writer (Compile time error). If i typecast it, it throws runtime error as below.
Code :
import java.io.FileWriter;
import java.io.IOException;
import org.pmw.tinylog.Configurator;
import org.pmw.tinylog.Logger;
import org.pmw.tinylog.writers.ConsoleWriter;
import org.pmw.tinylog.writers.Writer;
public class TestClass {
public static void main(String[] args) throws IOException {
Configurator.defaultConfig().writer(new ConsoleWriter()).addWriter((Writer) new FileWriter("data.txt")).activate();
Logger.info("welcome to tinylog logger.....");
}
}
Error :-
Exception in thread "main" java.lang.ClassCastException: java.io.FileWriter cannot be cast to org.pmw.tinylog.writers.Writer at TestClass.main(TestClass.java:12)
Please help us :).