I need to make a condition based on the Log of my Java project.
Ex:
Enquanto(TextoDoLog == "PalavraTal"){
faça algo;
}
But I do not know if I have to create some class, or method, how to handle it.
I need to make a condition based on the Log of my Java project.
Ex:
Enquanto(TextoDoLog == "PalavraTal"){
faça algo;
}
But I do not know if I have to create some class, or method, how to handle it.
Java has logging frameworks , Log4j the most famous of them.
As with any framework, a previous configuration is necessary so that you can use it, but in the case of Log4j it is very simple.
Once configured, you can "log" your application only with method calls like the following:
logger.error("Ocorreu um erro aqui");
logger.warn("Atenção!");
logger.info("Informação :P");
Among others ...
With Log4j you can configure how the log will be stored: whether it will only be displayed on the server console, whether it will save a separate file and so on.
In addition, you can format how the log is stored, including the level (error, info, warn, debug and etc), date, time, the class / strong> where the log was created.
Here has a tutorial how to configure and use Log4j.