You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ana Alamo <aa...@bilbomatica.es> on 2002/01/22 16:52:36 UTC
Log4j
Excuse me, for example i have this java's program, i execute tis and any log sentence was show
because this sentences ignores all >>> cat.getDefaultHierarchy().disableAll();
but for example i want to see what kind of error occurs or i want to see the logs sentence.
What is the meanning of this:
"In cases of problems whit an application, tecnical support can re-enable logging by setting
the log2.disableOverride system property without changing the binary al client's site"
How it´s possible to do that change, can you explain me?
i didn´t understand how can
package com.foo.MyApp1;
import org.apache.log4j.*;
import com.foo.Bar;
public class MyApp2 {
static Category cat = Category.getInstance(MyApp2.class);
public MyApp2() {
}
public static void main(String[] args) throws Exception
{
Category root = Category.getRoot();
Layout layout = new PatternLayout("%5p [%t] (%F:%L) %-5p %c{2} %x - %m%n");
root.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT));
root.addAppender(new FileAppender(layout, "ejemplo.log"));
Category barcat = Category.getInstance("com.foo.Bar");
barcat.setPriority(Priority.INFO);
cat.setPriority(Priority.INFO);
cat.getDefaultHierarchy().disableAll();
cat.info("la clase com.foo.Bar tiene definido como Prioridad -> " + barcat.getPriority());
cat.info("la clase com.foo.MyApp1 tiene definido como Prioridad -> " + cat.getPriority());
// cat.setPriority(Priority.WARN);
int i=1;
cat.debug("Mensaje Nº" + (i++));
cat.fatal("Mensaje Nº" + (i++) + " --> se va a ver porque es FATAL>=INFO");
barcat.info("Mensaje Nº" + (i++) + "--> se va a ver porque es INFO>=INFO");
barcat.warn("Mensaje Nº" + (i++) + "--> se va a ver porque es WARN>=INFO");
try {
cat.info(" divisón entre cero");
int inNumero = 10/0;
cat.info("resultado de la division ->" + inNumero);
} catch (Exception ex) {
cat.error(ex.getMessage());
}
}
}