Skip to content

Instantly share code, notes, and snippets.

@thaniaclair
Last active August 29, 2015 23:35
Show Gist options
  • Save thaniaclair/60031 to your computer and use it in GitHub Desktop.
Save thaniaclair/60031 to your computer and use it in GitHub Desktop.
Log4j, Teste
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import org.apache.log4j.BasicConfigurator;
public class LoggingTest {
static Logger logger = Logger.getLogger(LoggingTest.class);
public static void main(String[] args) {
BasicConfigurator.configure();
logger.setLevel(Level.INFO);
logger.debug("Isso nao vai aparecer...");
logger.info("Inicializando...");
try {
throw new Exception("Loga esse, Log4J!?");
} catch (Exception e) {
logger.error("Oops, deu erro: " + e.getMessage());
}
logger.info("Finalizando...");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment