Java Code Examples for org.apache.log4j.LogManager#shutdown()
The following examples show how to use
org.apache.log4j.LogManager#shutdown() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From ripme with MIT License | 6 votes |
/** * Configures root logger, either for FILE output or just console. */ public static void configureLogger() { LogManager.shutdown(); String logFile = getConfigBoolean("log.save", false) ? "log4j.file.properties" : "log4j.properties"; try (InputStream stream = Utils.class.getClassLoader().getResourceAsStream(logFile)) { if (stream == null) { PropertyConfigurator.configure("src/main/resources/" + logFile); } else { PropertyConfigurator.configure(stream); } LOGGER.info("Loaded " + logFile); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } }
Example 2
Source File: ApplicationMaster.java From hadoop with Apache License 2.0 | 6 votes |
/** * @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); } }
Example 3
Source File: TestAuditLogs.java From big-c with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: JstormMaster.java From jstorm with Apache License 2.0 | 6 votes |
/** * @param args Command line args */ public static void main(String[] args) { boolean result = false; try { JstormMaster appMaster = new JstormMaster(); LOG.info("Initializing Jstorm Master!"); boolean doRun = appMaster.init(args); if (!doRun) { System.exit(JOYConstants.EXIT_SUCCESS); } appMaster.run(); // LRS won't finish at all result = appMaster.finish(); } catch (Throwable t) { LOG.fatal("Error running JstormMaster", t); LogManager.shutdown(); ExitUtil.terminate(JOYConstants.EXIT_FAIL1, t); } if (result) { LOG.info("Application Master completed successfully. exiting"); System.exit(JOYConstants.EXIT_SUCCESS); } else { LOG.info("Application Master failed. exiting"); System.exit(JOYConstants.EXIT_FAIL2); } }
Example 5
Source File: AuditServiceTest.java From knox with Apache License 2.0 | 5 votes |
@After public void tearDown() { CollectAppender.queue.clear(); LogManager.shutdown(); String absolutePath = "target/audit"; File db = new File( absolutePath + ".db" ); if( db.exists() ) { assertThat( "Failed to delete audit store db file.", db.delete(), is( true ) ); } File lg = new File( absolutePath + ".lg" ); if( lg.exists() ) { assertThat( "Failed to delete audit store lg file.", lg.delete(), is( true ) ); } PropertyConfigurator.configure( ClassLoader.getSystemResourceAsStream( "audit-log4j.properties" ) ); }
Example 6
Source File: Log4JLogger.java From ignite with Apache License 2.0 | 5 votes |
/** * Cleans up the logger configuration. Should be used in unit tests only for sequential tests run with * different configurations */ static void cleanup() { synchronized (mux) { if (inited) LogManager.shutdown(); inited = false; } }
Example 7
Source File: TaskLog.java From hadoop with Apache License 2.0 | 5 votes |
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(); }
Example 8
Source File: Server.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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; }
Example 9
Source File: StoreAndForwardAppenderTest.java From knox with Apache License 2.0 | 5 votes |
@After public void cleanup() throws IOException { LogManager.shutdown(); String absolutePath = "target/audit"; File db = new File( absolutePath + ".db" ); if( db.exists() ) { assertThat( "Failed to delete audit store db file.", db.delete(), is( true ) ); } File lg = new File( absolutePath + ".lg" ); if( lg.exists() ) { assertThat( "Failed to delete audit store lg file.", lg.delete(), is( true ) ); } PropertyConfigurator.configure( ClassLoader.getSystemResourceAsStream( "audit-log4j.properties" ) ); }
Example 10
Source File: OLATServlet.java From olat with Apache License 2.0 | 5 votes |
/** */ @Override public void destroy() { log.info("*** Destroying OLAT servlet."); log.info("*** Shutting down the logging system - do not use logger after this point!"); LogManager.shutdown(); }
Example 11
Source File: TezChild.java From incubator-tez with Apache License 2.0 | 5 votes |
private void shutdown() { executor.shutdownNow(); if (taskReporter != null) { taskReporter.shutdown(); } RPC.stopProxy(umbilical); DefaultMetricsSystem.shutdown(); LogManager.shutdown(); }
Example 12
Source File: PowerSwitch.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
@Override public void onTerminate() { LogManager.shutdown(); super.onTerminate(); }
Example 13
Source File: AsyncAppenderLog4j1Benchmark.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@TearDown(Level.Trial) public void down() { LogManager.shutdown(); new File("perftest.log").delete(); }
Example 14
Source File: RunLog4j1.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@Override public void shutdown() { LogManager.shutdown(); }
Example 15
Source File: Log4jLoggerServiceImpl.java From gflogger with Apache License 2.0 | 4 votes |
@Override public void stop() { LogManager.shutdown(); }
Example 16
Source File: MRAppMaster.java From big-c with Apache License 2.0 | 4 votes |
@Override protected void serviceStop() throws Exception { super.serviceStop(); LogManager.shutdown(); }
Example 17
Source File: MRAppMaster.java From hadoop with Apache License 2.0 | 4 votes |
@Override protected void serviceStop() throws Exception { super.serviceStop(); LogManager.shutdown(); }
Example 18
Source File: StreamingContainer.java From Bats with Apache License 2.0 | 4 votes |
/** * Initialize container. Establishes heartbeat connection to the master * distribute through the callback address provided on the command line. Deploys * initial modules, then enters the heartbeat loop, which will only terminate * once container receives shutdown request from the master. On shutdown, * after exiting heartbeat loop, shutdown all modules and terminate * processing threads. * * @param args * @throws Throwable */ public static void main(String[] args) throws Throwable { LoggerUtil.setupMDC("worker"); StdOutErrLog.tieSystemOutAndErrToLog(); logger.debug("PID: " + System.getenv().get("JVM_PID")); logger.info("Child starting with classpath: {}", System.getProperty("java.class.path")); String appPath = System.getProperty(PROP_APP_PATH); if (appPath == null) { logger.error("{} not set in container environment.", PROP_APP_PATH); System.exit(1); } int exitStatus = 1; // interpreted as unrecoverable container failure RecoverableRpcProxy rpcProxy = null; StreamingContainerUmbilicalProtocol umbilical = null; final String childId = System.getProperty(StreamingApplication.DT_PREFIX + "cid"); try { rpcProxy = new RecoverableRpcProxy(appPath, new Configuration()); umbilical = rpcProxy.getProxy(); StreamingContainerContext ctx = umbilical.getInitContext(childId); StreamingContainer stramChild = new StreamingContainer(childId, umbilical); logger.debug("Container Context = {}", ctx); stramChild.setup(ctx); try { /* main thread enters heartbeat loop */ stramChild.heartbeatLoop(); exitStatus = 0; } finally { stramChild.teardown(); } } catch (Error | Exception e) { LogFileInformation logFileInfo = LoggerUtil.getLogFileInformation(); logger.error("Fatal {} in container!", (e instanceof Error) ? "Error" : "Exception", e); /* Report back any failures, for diagnostic purposes */ try { umbilical.reportError(childId, null, ExceptionUtils.getStackTrace(e), logFileInfo); } catch (Exception ex) { logger.debug("Fail to log", ex); } } finally { if (rpcProxy != null) { rpcProxy.close(); } DefaultMetricsSystem.shutdown(); logger.info("Exit status for container: {}", exitStatus); LogManager.shutdown(); if (exitStatus != 0) { System.exit(exitStatus); } } }
Example 19
Source File: Log4jConfigurer.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Shut down log4j, properly releasing all file locks. * <p>This isn't strictly necessary, but recommended for shutting down * log4j in a scenario where the host VM stays alive (for example, when * shutting down an application in a J2EE environment). */ public static void shutdownLogging() { LogManager.shutdown(); }
Example 20
Source File: Log4jConfigurer.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Shut down log4j, properly releasing all file locks. * <p>This isn't strictly necessary, but recommended for shutting down * log4j in a scenario where the host VM stays alive (for example, when * shutting down an application in a J2EE environment). */ public static void shutdownLogging() { LogManager.shutdown(); }