本文整理汇总了Java中org.apache.logging.log4j.core.config.Configurator.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java Configurator.shutdown方法的具体用法?Java Configurator.shutdown怎么用?Java Configurator.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.config.Configurator
的用法示例。
在下文中一共展示了Configurator.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
String config = args.length == 0 ? "target/test-classes/log4j2-319.xml" : args[0];
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
try {
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 (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.");
} finally {
Configurator.shutdown(ctx);
}
}
示例2: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
String config = args.length == 0 ? "target/test-classes/log4j2-180.xml" : args[0];
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
try {
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 (Exception e) {
LOG.error("Error message.", e);
LOG.catching(Level.ERROR, e);
}
} finally {
Configurator.shutdown(ctx);
}
}
示例3: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
String config = args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml" : args[0];
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
try {
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"));
} finally {
Configurator.shutdown(ctx);
}
}
示例4: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
// System.out.println(System.getProperty("java.class.path"));
String config = args.length == 0 ? "target/test-classes/log4j2-272.xml" : args[0];
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
try {
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 (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.");
} finally {
Configurator.shutdown(ctx);
}
}
示例5: test
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public void test(final String[] args) {
System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
// System.out.println(System.getProperty("java.class.path"));
final String config = args == null || args.length == 0 ? "target/test-classes/log4j2-console-xex-ansi.xml"
: args[0];
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config);
final Logger logger = LogManager.getLogger(ConsoleAppenderJAnsiXExceptionMain.class);
try {
Files.getFileStore(Paths.get("?BOGUS?"));
} catch (final Exception e) {
final IllegalArgumentException logE = new IllegalArgumentException("Bad argument foo", e);
logger.error("Gotcha!", logE);
} finally {
Configurator.shutdown(ctx);
}
}
示例6: exit
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void exit(ExitCode code) {
if (code == null) {
return;
}
log.info(code);
Preferences.set("language", LanguageRegistry.getInstance().getCurrentLanguage().getName());
Preferences.savePreferences();
LoggerContext context = (LoggerContext) LogManager.getContext();
Configurator.shutdown(context);
System.exit(code.code());
}
示例7: stopCluster
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public final void stopCluster() throws Exception {
for (Node node : esNodes) {
try {
node.close();
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configurator.shutdown(context);
Thread.sleep(150);
} catch (Throwable e) {
e.printStackTrace();
}
}
esNodes.clear();
}
示例8: cleanup
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public void cleanup() {
try {
for (Thread thread : threads) {
thread.join();
}
} catch (InterruptedException e) {
}
Configurator.shutdown((LoggerContext) LogManager.getContext());
}
示例9: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(final String[] args) {
final LoggerContext ctx = Configurator.initialize(FormatterLoggerManualExample.class.getName(),
"target/test-classes/log4j2-console.xml");
try {
final User user = new User();
logger.debug("User %s with birthday %s", user.getName(), user.getBirthdayCalendar());
logger.debug("User %1$s with birthday %2$tm %2$te, %2$tY", user.getName(), user.getBirthdayCalendar());
logger.debug("Integer.MAX_VALUE = %,d", Integer.MAX_VALUE);
logger.debug("Long.MAX_VALUE = %,d", Long.MAX_VALUE);
} finally {
Configurator.shutdown(ctx);
}
}
示例10: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
"target/test-classes/log4j2-console-style-name-ansi.xml");
try {
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"));
} finally {
Configurator.shutdown(ctx);
}
}
示例11: validateXmlNoEvents
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
@Test
public void validateXmlNoEvents() throws Exception {
final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
file.delete();
Configurator.shutdown(this.loggerContext);
this.validateXmlSchema(file);
}
示例12: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
"target/test-classes/log4j2-console-highlight-default.xml");
try {
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"));
} finally {
Configurator.shutdown(ctx);
}
}
示例13: main
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
"target/test-classes/log4j2-console-highlight.xml");
try {
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"));
} finally {
Configurator.shutdown(ctx);
}
}
示例14: validateXmlSchemaThrowable
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
@Test
public void validateXmlSchemaThrowable() throws Exception {
final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
file.delete();
final Logger log = LogManager.getLogger("com.foo.Bar");
try {
throw new IllegalArgumentException("IAE");
} catch (final IllegalArgumentException e) {
log.warn("Message 1", e);
}
Configurator.shutdown(this.loggerContext);
this.validateXmlSchema(file);
}
示例15: validateXmlSchema
import org.apache.logging.log4j.core.config.Configurator; //导入方法依赖的package包/类
@Test
public void validateXmlSchema() throws Exception {
final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
file.delete();
final Logger log = LogManager.getLogger("com.foo.Bar");
log.warn("Message 1");
log.info("Message 2");
log.debug("Message 3");
Configurator.shutdown(this.loggerContext);
this.validateXmlSchema(file);
}