Hallo,
diese beiden Klassen habe ich nahezu unverändert aus der log4j-Doku auf Apache log4j 1.2 - Short introduction to log4j kopiert:
Warum wird diese Ausgabe erzeugt? Warum doppelte Loggings?
diese beiden Klassen habe ich nahezu unverändert aus der log4j-Doku auf Apache log4j 1.2 - Short introduction to log4j kopiert:
Java:
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import de.forum.Bar;
public class LogTest
{
// Define a static logger variable so that it references the
// Logger instance named "LogTest".
static Logger logger = Logger.getLogger(LogTest.class);
public static void main(String[] args)
{
// Set up a simple configuration that logs on the console.
BasicConfigurator.configure();
logger.info("Entering application.");
Bar bar = new Bar();
bar.doIt();
logger.info("Exiting application.");
}
}
Java:
package de.forum;
import org.apache.log4j.Logger;
public class Bar
{
static Logger logger = Logger.getLogger(Bar.class);
public void doIt()
{
logger.debug("Did it again!");
}
}
Warum wird diese Ausgabe erzeugt? Warum doppelte Loggings?
Code:
- Entering application.
0 [main] INFO LogTest - Entering application.
- Exiting application.
0 [main] INFO LogTest - Exiting application.