use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class ConsoleAppenderAnsiStyleJira180Main method main.
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
final String config = args.length == 0 ? "target/test-classes/log4j2-180.xml" : args[0];
try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) {
LOG.fatal("Fatal message.");
LOG.error("Error message.");
LOG.warn("Warning message.");
LOG.info("Information message.");
LOG.debug("Debug message.");
LOG.trace("Trace message.");
try {
throw new NullPointerException();
} catch (final Exception e) {
LOG.error("Error message.", e);
LOG.catching(Level.ERROR, e);
}
}
}
use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class ConsoleAppenderAnsiStyleJira319Main method main.
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
final String config = args.length == 0 ? "target/test-classes/log4j2-319.xml" : args[0];
try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config)) {
LOG.fatal("Fatal message.");
LOG.error("Error message.");
LOG.warn("Warning message.");
LOG.info("Information message.");
LOG.debug("Debug message.");
LOG.trace("Trace message.");
try {
throw new NullPointerException();
} catch (final Exception e) {
LOG.error("Error message.", e);
LOG.catching(Level.ERROR, e);
}
LOG.warn("this is ok \n And all \n this have only\t\tblack colour \n and here is colour again?");
LOG.info("Information message.");
}
}
use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class ConsoleAppenderAnsiStyleNameLayoutMain method main.
public static void main(final String[] args) {
try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), "target/test-classes/log4j2-console-style-name-ansi.xml")) {
LOG.fatal("Fatal message.");
LOG.error("Error message.");
LOG.warn("Warning message.");
LOG.info("Information message.");
LOG.debug("Debug message.");
LOG.trace("Trace message.");
LOG.error("Error message.", new IOException("test"));
}
}
use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class XmlConfigurationPropsTest method testDefaultStatus.
@Test
public void testDefaultStatus() {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG1);
System.setProperty(Constants.LOG4J_DEFAULT_STATUS_LEVEL, "WARN");
try {
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
final Configuration config = ctx.getConfiguration();
assertTrue("Configuration is not an XmlConfiguration", config instanceof XmlConfiguration);
} finally {
System.clearProperty(Constants.LOG4J_DEFAULT_STATUS_LEVEL);
}
}
use of org.apache.logging.log4j.core.LoggerContext in project logging-log4j2 by apache.
the class XmlConfigurationPropsTest method cleanupClass.
@AfterClass
public static void cleanupClass() {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
final LoggerContext ctx = LoggerContext.getContext();
ctx.reconfigure();
StatusLogger.getLogger().reset();
}
Aggregations