本文整理匯總了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();
}