本文整理汇总了Java中org.apache.log4j.LogManager.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java LogManager.shutdown方法的具体用法?Java LogManager.shutdown怎么用?Java LogManager.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.LogManager
的用法示例。
在下文中一共展示了LogManager.shutdown方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureLogger
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
* Configures root logger, either for FILE output or just console.
*/
public static void configureLogger() {
LogManager.shutdown();
String logFile;
if (getConfigBoolean("log.save", false)) {
logFile = "log4j.file.properties";
}
else {
logFile = "log4j.properties";
}
InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile);
if (stream == null) {
PropertyConfigurator.configure("src/main/resources/" + logFile);
} else {
PropertyConfigurator.configure(stream);
}
logger.info("Loaded " + logFile);
try {
stream.close();
} catch (IOException e) { }
}
示例2: testWriteHeaderAndFooter
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Test
public void testWriteHeaderAndFooter() throws Exception
{
initialize("TestSNSAppender/testWriteHeaderAndFooter.properties");
logger.debug("message");
// must retrieve writer before we shut down
MockSNSWriter writer = appender.getMockWriter();
LogManager.shutdown();
assertEquals("number of messages written to log", 3, writer.messages.size());
assertEquals("header is first", HeaderFooterLayout.HEADER, writer.getMessage(0));
assertEquals("message is second", "message", writer.getMessage(1));
assertEquals("footer is last", HeaderFooterLayout.FOOTER, writer.getMessage(2));
}
示例3: main
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
* @param args Command line args
*/
public static void main(String[] args) {
boolean result = false;
try {
ApplicationMaster appMaster = new ApplicationMaster();
LOG.info("Initializing ApplicationMaster");
boolean doRun = appMaster.init(args);
if (!doRun) {
System.exit(0);
}
appMaster.run();
result = appMaster.finish();
} catch (Throwable t) {
LOG.fatal("Error running ApplicationMaster", t);
LogManager.shutdown();
ExitUtil.terminate(1, t);
}
if (result) {
LOG.info("Application Master completed successfully. exiting");
System.exit(0);
} else {
LOG.info("Application Master failed. exiting");
System.exit(2);
}
}
示例4: configureAuditLogs
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
private void configureAuditLogs() throws IOException {
// Shutdown the LogManager to release all logger open file handles.
// Unfortunately, Apache commons logging library does not provide
// means to release underlying loggers. For additional info look up
// commons library FAQ.
LogManager.shutdown();
File file = new File(auditLogFile);
if (file.exists()) {
assertTrue(file.delete());
}
Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
// disable logging while the cluster startup preps files
logger.setLevel(Level.OFF);
PatternLayout layout = new PatternLayout("%m%n");
RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
logger.addAppender(appender);
}
示例5: testWriteHeaderAndFooter
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Test
public void testWriteHeaderAndFooter() throws Exception
{
initialize("TestCloudWatchAppender/testWriteHeaderAndFooter.properties");
logger.debug("blah blah blah");
// must retrieve writer before we shut down
MockCloudWatchWriter mockWriter = appender.getMockWriter();
LogManager.shutdown();
assertEquals("number of messages written to log", 3, mockWriter.messages.size());
assertEquals("header is first", HeaderFooterLayout.HEADER, mockWriter.getMessage(0));
assertEquals("footer is last", HeaderFooterLayout.FOOTER, mockWriter.getMessage(2));
}
示例6: testWriteHeaderAndFooter
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Test
public void testWriteHeaderAndFooter() throws Exception
{
initialize("TestKinesisAppender/testWriteHeaderAndFooter.properties");
logger.debug("blah blah blah");
// must retrieve writer before we shut down
MockKinesisWriter writer = appender.getMockWriter();
LogManager.shutdown();
assertEquals("number of messages written to log", 3, writer.messages.size());
assertEquals("header is first", HeaderFooterLayout.HEADER, writer.getMessage(0));
assertEquals("footer is last", HeaderFooterLayout.FOOTER, writer.getMessage(2));
}
示例7: syncLogsShutdown
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
public static synchronized void syncLogsShutdown(
ScheduledExecutorService scheduler)
{
// flush standard streams
//
System.out.flush();
System.err.flush();
if (scheduler != null) {
scheduler.shutdownNow();
}
// flush & close all appenders
LogManager.shutdown();
}
示例8: destroy
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
/**
* Destroys the server.
* <p>
* All services are destroyed in reverse order of initialization, then the
* Log4j framework is shutdown.
*/
public void destroy() {
ensureOperational();
destroyServices();
log.info("Server [{}] shutdown!", name);
log.info("======================================================");
if (!Boolean.getBoolean("test.circus")) {
LogManager.shutdown();
}
status = Status.SHUTDOWN;
}
示例9: serviceStop
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@Override
protected void serviceStop() throws Exception {
super.serviceStop();
LogManager.shutdown();
}
示例10: destroyLog4j
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
private void destroyLog4j() {
LogManager.shutdown();
}
示例11: destroyLog4j
import org.apache.log4j.LogManager; //导入方法依赖的package包/类
@PreDestroy
private void destroyLog4j() {
LogManager.shutdown();
}