/** * Loads the test-specific Log4J configuration and resets the environment. */ public void setUp(String propertiesName) throws Exception { URL config = ClassLoader.getSystemResource(propertiesName); assertNotNull("missing configuration: " + propertiesName, config); LogManager.resetConfiguration(); PropertyConfigurator.configure(config); localLogger = Logger.getLogger(getClass()); runId = String.valueOf(System.currentTimeMillis()); resourceName = "SNSAppenderIntegrationTest-" + runId; System.setProperty("SNSAppenderIntegrationTest.resourceName", resourceName); localSNSclient = AmazonSNSClientBuilder.defaultClient(); localSQSclient = AmazonSQSClientBuilder.defaultClient(); }
/** * On change event */ void handleOnChange(File logFile) { try { long lastModif = logFile.lastModified(); if (lastModif > logFileLastModified) { logFileLastModified = lastModif; logger.debug("Reload log4j configuration from " + logFile.getAbsolutePath()); new PropertyConfigurator().doConfigure( logFile.getAbsolutePath(), LogManager.getLoggerRepository()); logFileWarning = false; } } catch (Exception e) { if (!logFileWarning) { logFileWarning = true; logger.error(logFile.getAbsolutePath(), e); } } }
public static void noUiStart() throws Exception{ AppConfig.firstInit(); prod = AppConfig.getProd(); appFileUtil = new AppFileUtil(); if(!appFileUtil.success()){ System.err.println(appFileUtil.getErrorMessage()); System.exit(-1); } // ignore everything else because this means that we're in a jar file, so the app won't work // if it doesn't think that we're prod. PropertyConfigurator.configure(appFileUtil.getLog4JFile().getAbsolutePath()); AppConfig.init(); String defaultLocationString = AppConfig.config.getString(AppConfig.WORLD_LOCATION); File defaultLocation = new File(defaultLocationString); defaultLocation.mkdirs(); String relativePath = new File(".").toURI().relativize(defaultLocation.toURI()).getPath(); AppConfig.saveDefaultWorldLocation("./" + relativePath); App.worldFileUtil = new WorldFileUtil(new File(AppConfig.config.getString(AppConfig.WORLD_LOCATION))); Backend.start(); }
private void setupLog4j(String appName) { // InputStream inStreamLog4j = getClass().getResourceAsStream("/log4j.properties"); String propFileName = appName + ".log4j.properties"; File f = new File("./" + propFileName); if (f.exists()) { try { InputStream inStreamLog4j = new FileInputStream(f); Properties propertiesLog4j = new Properties(); propertiesLog4j.load(inStreamLog4j); PropertyConfigurator.configure(propertiesLog4j); } catch (Exception e) { e.printStackTrace(); BasicConfigurator.configure(); } } else { BasicConfigurator.configure(); } // logger.setLevel(Level.TRACE); logger.debug("log4j configured"); }
public static void init(List<String> locationPatterns) throws Exception { if (inited) { return; } synchronized (LOCK) { if (inited) { return; } PropertiesLoader loader = new PropertiesLoader(locationPatterns); Properties properties = loader.load(); if (properties.isEmpty()) { throw new Exception("can not find resource " + locationPatterns); } PropertyConfigurator.configure(properties); inited = true; // 如果最高优先级的文件是在磁盘上,且有写权限,则将merge的结果输出到该目录,方便维护时观察生效的参数 outputFile(loader.getFoundResList(), properties); } }
/** * 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) { } }
/** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { String file = this.getServletContext().getRealPath(this.getInitParameter("log4j")); //从web.xml配置读取,名字一定要和web.xml配置一致 if(file != null){ PropertyConfigurator.configure(file); } // Put your code here new CrawlerServer(DefaultConfig.serverPort).start(); try { new WebSocket(DefaultConfig.socketPort).start(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void initConf() { try { String logpath = context.getConfigPath() + File.separator + "log4j.properties"; PropertyConfigurator.configure(logpath); logger.info(String.format("log4j path:%s", logpath)); String serverpath = context.getConfigPath() + File.separator + "server.properties"; NettyServerConfig config = GuiceDI.getInstance(NettyServerConfig.class); PropertiesHelper pro = new PropertiesHelper(serverpath); config.setSelectorThreads(pro.getInt("selectorThreads")); config.setWorkerThreads(pro.getInt("workerThreads")); config.setListenPort(pro.getInt("server.Port")); config.setUsezk(pro.getBoolean("use.zk")); config.setZkhosts(pro.getString("zk.hosts")); logger.info(JSON.toJSONString(config)); } catch (Exception e) { logger.error("", e); } }
public static void main(String... args) throws Exception { PropertyConfigurator.configure("D:/log4j.properties"); try { List<Replica> members = Lists.newArrayList(); members.add(Replica.fromString("localhost:10000")); members.add(Replica.fromString("localhost:10002")); File logDir = new File("D:/raft1"); logDir.mkdir(); // configure the service RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10001")).members(members).logDir(logDir).timeout(300).build(new Test2()); // start this replica raft.startAsync().awaitRunning(); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String... args) throws Exception { PropertyConfigurator.configure("D:/log4j.properties"); try { List<Replica> members = Lists.newArrayList(); members.add(Replica.fromString("localhost:10000")); members.add(Replica.fromString("localhost:10001")); File logDir = new File("D:/raft2"); logDir.mkdir(); // configure the service RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10002")).members(members).logDir(logDir).timeout(300).build(new Test3()); // start this replica raft.startAsync().awaitRunning(); // let's commit some things // for (int i = 0; i < 10; i++) { // raft.commit(new byte[] { 'O', '_', 'o' }); // } } catch (Exception e) { e.printStackTrace(); } }
public static void main(String... args) throws Exception { PropertyConfigurator.configure("D:/log4j.properties"); try { List<Replica> members = Lists.newArrayList(); members.add(Replica.fromString("localhost:10001")); members.add(Replica.fromString("localhost:10002")); File logDir = new File("D:/raft"); logDir.mkdir(); // configure the service RaftService raft = RaftService.newBuilder().local(Replica.fromString("localhost:10000")).members(members).logDir(logDir).timeout(300).build(new Test()); // start this replica Service guavaservice = raft.startAsync(); guavaservice.awaitRunning(); // let's commit some things // for (int i = 0; i < 10; i++) { // raft.commit(new byte[] { 'O', '_', 'o' }); // } } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { try { RateLimiter limit = RateLimiter.create(100d); PropertyConfigurator.configure("conf/log4j.properties"); while (true) { if (limit.tryAcquire()) { final HelloCommand command = new HelloCommand(); // System.out.println("result: " + command.execute()); // System.out.println(""); Future<String> future = command.queue(); System.out.println("result: " + future.get()); System.out.println(""); } } // Observable<String> observe = command.observe(); // observe.asObservable().subscribe((result) -> { // System.out.println(result); // }); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { PropertyConfigurator.configure("conf/log4j.properties"); Method[] methods = HelloImpl.class.getDeclaredMethods(); for (Method method : methods) { System.out.println(method.getName()); Class<?>[] param = method.getParameterTypes(); System.out.println(JSON.toJSONString(param)); try { Method m2 = RMethodUtils.searchMethod(HelloImpl.class, method.getName(), param); if (m2 == null) { System.out.println("null"); } else { System.out.println(method.getName()); } } catch (NoSuchMethodException e) { e.printStackTrace(); } } }
public static void main(String[] args) { try { PropertyConfigurator.configure("conf/log4j.properties"); final Hello hello = ProxyFactory.create(Hello.class, "test", null, null); System.out.println("result: " + hello.say("xiaoming")); System.out.println(""); System.out.println("result: " + hello.hi(2)); System.out.println(""); // System.out.println("result: " + hello.hi(2)); // System.out.println(""); // System.out.println("result: " + hello.hi(2)); // System.out.println(""); // System.out.println("result: " + hello.hi(2)); System.out.println(""); // } catch (Exception e) { e.printStackTrace(); } }
@Test public void testbean() { try { PropertyConfigurator.configure("conf/log4j.properties"); final Hello hello = ProxyFactory.create(Hello.class, "test", null, null); User u = new User(); u.setAge(12); u.setName("nana"); u.setStart(new Date()); System.out.println(""); u.setName("lua"); System.out.println(""); } catch (Exception e) { e.printStackTrace(); } }
@Test public void testList() { try { PropertyConfigurator.configure("conf/log4j.properties"); final Hello hello = ProxyFactory.create(Hello.class, "test", null, null); User u = new User(); u.setAge(12); u.setName("nana"); u.setStart(new Date()); System.out.println("result: " + hello.getall(u)); System.out.println(""); u.setName("lua"); System.out.println("result: " + hello.getall(u)); System.out.println(""); } catch (Exception e) { e.printStackTrace(); } }
private void initLogging(String confDir) { if (System.getProperty("log4j.configuration") == null) { System.setProperty("log4j.defaultInitOverride", "true"); boolean fromClasspath = true; File log4jConf = new File(confDir, LOG4J_PROPERTIES).getAbsoluteFile(); if (log4jConf.exists()) { PropertyConfigurator.configureAndWatch(log4jConf.getPath(), 1000); fromClasspath = false; } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL log4jUrl = cl.getResource(LOG4J_PROPERTIES); if (log4jUrl != null) { PropertyConfigurator.configure(log4jUrl); } } LOG = LoggerFactory.getLogger(KMSWebApp.class); LOG.debug("KMS log starting"); if (fromClasspath) { LOG.warn("Log4j configuration file '{}' not found", LOG4J_PROPERTIES); LOG.warn("Logging with INFO level to standard output"); } } else { LOG = LoggerFactory.getLogger(KMSWebApp.class); } }
@Test public void testSort() { PropertyConfigurator.configure(getClass().getResource("/log4j.properties")); PortMethod[] methods = { PortMethod.POST, PortMethod.GET, PortMethod.PUT, PortMethod.DELETE }; Arrays.sort(methods); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.POST) >= 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.GET) >= 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.PUT) >= 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.DELETE) >= 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.OPTIONS) < 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.TARCE) < 0); Assert.assertTrue(Arrays.binarySearch(methods, PortMethod.HEAD) < 0); }
public static Logger getLogger(@SuppressWarnings("rawtypes") Class clazz) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL url = loader.getResource("log4j.properties"); String path; if (url==null) { String currPath = LoggerFactory.class.getProtectionDomain().getCodeSource().getLocation().getFile(); File file = new File(currPath); path = file.getParentFile().getParentFile() + "/conf/log4j.properties"; if (!new File(path).exists()) { throw new ExceptionInInitializerError("[opencron] error: can not found log4j.properties..."); } }else { path = url.getPath(); } PropertyConfigurator.configure(path); return org.slf4j.LoggerFactory.getLogger(clazz); }
/** * On change event */ void handleOnChange(File logFile) { try { long lastModif = logFile.lastModified(); if (lastModif > logFileLastModified) { logFileLastModified = lastModif; LOGGER.debug("Reload log4j configuration from " + logFile.getAbsolutePath()); new PropertyConfigurator().doConfigure(logFile.getAbsolutePath(), LogManager.getLoggerRepository()); logFileWarning = false; } } catch (Exception e) { if (!logFileWarning) { logFileWarning = true; LOGGER.error(logFile.getAbsolutePath(), e); } } }
/** * On change event */ void handleOnChange(File logFile) { try { long lastModif = logFile.lastModified(); if (lastModif > logFileLastModified) { logFileLastModified = lastModif; LOGGER.debug("Reload log4j configuration from " + logFile.getAbsolutePath()); new PropertyConfigurator().doConfigure( logFile.getAbsolutePath(), LogManager.getLoggerRepository()); logFileWarning = false; } } catch (Exception e) { if (!logFileWarning) { logFileWarning = true; LOGGER.error(logFile.getAbsolutePath(), e); } } }
@Test public void testLoggerReconfiguration() throws Exception { logger.setLevel(Level.ERROR); Map<String, Long> expectedCounts = getCurrentCounts(); expectedCounts.compute("total", (s, aLong) -> aLong + 1); expectedCounts.compute("error", (s, aLong) -> aLong + 1); Properties properties = new Properties(); properties.setProperty("log4j.rootCategory", "INFO,TestLog"); properties.setProperty("log4j.appender.TestLog", "org.apache.log4j.ConsoleAppender"); properties.setProperty("log4j.appender.TestLog.layout", "org.apache.log4j.PatternLayout"); PropertyConfigurator.configure(properties); logger.error("error!"); assertEquals(expectedCounts, getCurrentCounts()); }
private static void setUpExperimentalLogger(File pathF) throws IOException { Logger.getRootLogger().removeAllAppenders(); log.removeAllAppenders(); PropertyConfigurator.configure("resource/log4jproperties.txt"); FileAppender resultAppender = new FileAppender( new PatternLayout("%m"), new File(pathF, "result.txt").toString(), false); LevelRangeFilter infoFilter = new LevelRangeFilter(); infoFilter.setLevelMin(Level.INFO); infoFilter.setLevelMax(Level.FATAL); infoFilter.setAcceptOnMatch(true); resultAppender.addFilter(infoFilter); log.addAppender(resultAppender); Logger.getLogger(iBench.class).addAppender(resultAppender); }
private static void setUpConfigLogger(File pathF, String configName) throws IOException { Logger.getRootLogger().removeAllAppenders(); String nameSuffix = configName.replace(".txt", ""); PropertyConfigurator.configure("resource/log4jproperties.txt"); FileAppender logFileAppender = new FileAppender( new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"), new File(pathF, "log_" + nameSuffix + ".txt").toString(), false); Logger.getRootLogger().addAppender(logFileAppender); if (opt.logToConsole) Logger.getRootLogger().addAppender(new ConsoleAppender( new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"))); }
@Test(expected = EventDeliveryException.class) public void testSlowness() throws Throwable { ch = new SlowMemoryChannel(2000); Configurables.configure(ch, new Context()); configureSource(); props.put("log4j.appender.out2.Timeout", "1000"); props.put("log4j.appender.out2.layout", "org.apache.log4j.PatternLayout"); props.put("log4j.appender.out2.layout.ConversionPattern", "%-5p [%t]: %m%n"); PropertyConfigurator.configure(props); Logger logger = LogManager.getLogger(TestLog4jAppender.class); Thread.currentThread().setName("Log4jAppenderTest"); int level = 10000; String msg = "This is log message number" + String.valueOf(1); try { logger.log(Level.toLevel(level), msg); } catch (FlumeException ex) { throw ex.getCause(); } }
public Property() { PropertyConfigurator.configure(this.getClass().getResourceAsStream("log4j_custom.properties")); Logger l1 = Logger.getLogger("P2P"); Appender a = new CustomAppender(); l1.addAppender(a); l1 = Logger.getLogger("BlockchainManager"); l1.addAppender(a); l1 = Logger.getLogger("DbManager"); l1.addAppender(a); l1 = Logger.getLogger("CrypDist"); l1.addAppender(a); try { Config.PRIVATE_KEY = new String((IOUtils.toByteArray(getClass().getResourceAsStream("private.pem"))) ); } catch (Exception e) { } }
protected void configureLogging() { Properties props = new Properties(); props.setProperty("log4j.rootLogger", "DEBUG, A1"); props.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender"); props.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout"); props.setProperty("log4j.appender.A1.layout.ConversionPattern","%-5p %c{2}: %m%n"); props.setProperty("log4j.logger.org.hibernate","INFO"); props.setProperty("log4j.logger.org.hibernate.cfg","WARN"); props.setProperty("log4j.logger.org.hibernate.cache.EhCacheProvider","ERROR"); props.setProperty("log4j.logger.org.unitime.commons.hibernate","INFO"); props.setProperty("log4j.logger.net","INFO"); props.setProperty("log4j.logger.org.unitime.timetable.onlinesectioning","WARN"); props.setProperty("log4j.logger.org.unitime.timetable.onlinesectioning.test","INFO"); props.setProperty("log4j.logger." + OnlineSectioningTestFwk.class.getName(), "INFO"); props.setProperty("log4j.logger.org.cpsolver.ifs.util.JProf", "INFO"); props.setProperty("log4j.logger.org.jgroups", "INFO"); props.setProperty("log4j.logger.net.sf.ehcache.distribution.jgroups", "WARN"); props.setProperty("log4j.logger.org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory", "ERROR"); props.setProperty("log4j.logger.net.sf.ehcache.distribution.jgroups.JGroupsCacheReceiver", "ERROR"); props.setProperty("log4j.logger.org.unitime.timetable.solver.jgroups.DummySolverServer", "INFO"); PropertyConfigurator.configure(props); }
private static void configureLogging(Properties properties) { PropertyConfigurator.configure(properties); Logger log = Logger.getRootLogger(); log.info("-----------------------------------------------------------------------"); log.info("UniTime Log File"); log.info(""); log.info("Created: " + new Date()); log.info(""); log.info("System info:"); log.info("System: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch")); log.info("CPU: " + System.getProperty("sun.cpu.isalist") + " endian:" + System.getProperty("sun.cpu.endian") + " encoding:" + System.getProperty("sun.io.unicode.encoding")); log.info("Java: " + System.getProperty("java.vendor") + ", " + System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version", System.getProperty("java.version"))); log.info("User: " + System.getProperty("user.name")); log.info("Timezone: " + System.getProperty("user.timezone")); log.info("Working dir: " + System.getProperty("user.dir")); log.info("Classpath: " + System.getProperty("java.class.path")); log.info("Memory: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + " MB"); log.info("Cores: " + Runtime.getRuntime().availableProcessors()); log.info(""); }
public static void main(String[] args) throws IOException { PropertyConfigurator.configure("log4j.info"); BufferedReader reader = new BufferedReader(new FileReader(args[0])); FileOutputStream out = new FileOutputStream(new File("/usr/local/RAID/geonames.nt")); String buffer = null; int count = 0; while ((buffer = reader.readLine()) != null) { if (++count % 2 == 0) { logger.debug("processing xml: " + buffer); Model model = ModelFactory.createDefaultModel() ; model.read(new StringReader(buffer), null, "RDF/XML"); model.write(out, "N-TRIPLE"); } else { logger.info("skipping: " + buffer); } } reader.close(); }
public static void main(@NotNull @NonNls String[] args) throws Exception { PropertyConfigurator.configure(System.getProperty("user.dir") + "/log4j.properties"); logger.warn("StrictFP | Back-end"); logger.info("StrictFP Back-end is now running..."); Server server = new Server(Constant.SERVER.SERVER_PORT); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/api/v0"); server.setHandler(context); server.setStopAtShutdown(true); // 像下面这行一样 context.addServlet(new ServletHolder(new GetQuiz()), "/misc/getquiz"); context.addServlet(new ServletHolder(new TimeLine()), "/timeline"); context.addServlet(new ServletHolder(new Counter()), "/misc/counter"); context.addServlet(new ServletHolder(new User()), "/user"); context.addServlet(new ServletHolder(new Heartbeat()), "/misc/heartbeat"); context.addServlet(new ServletHolder(new SafeCheck()), "/misc/safecheck"); context.addServlet(new ServletHolder(new CheckCert()), "/auth/check_cert"); // server.start(); server.join(); }
public static void main(String[] args) throws Exception { // PRODUCTION mode needs to be determined before we get here... AppConfig.firstInit(); prod = AppConfig.getProd(); appFileUtil = new AppFileUtil(); if(!appFileUtil.success()){ System.err.println(appFileUtil.getErrorMessage()); Platform.runLater(new Runnable(){ public void run(){ Alert al = new Alert(AlertType.ERROR); al.setResizable(true); for(Node n : al.getDialogPane().getChildren()){ if(n instanceof Label){ ((Label)n).setMinHeight(Region.USE_PREF_SIZE); } } al.setContentText(appFileUtil.getErrorMessage()); al.setHeaderText("FWM Startup Error"); al.showAndWait(); System.exit(-1); } }); return; } // ignore everything else because this means that we're in a jar file, so the app won't work // if it doesn't think that we're prod. PropertyConfigurator.configure(appFileUtil.getLog4JFile().getAbsolutePath()); AppConfig.init(); HotkeyController.init(); log.debug("Currently prod? " + prod); log.debug(retGlobalResource("/src/main/webapp/WEB-INF/images/FWM-icon.png").getFile()); launch(args); }
public void configure(Context context) { batchUpperLimit = context.getInteger("batchUpperLimit",1); PropertyConfigurator.configure(PropertyUtil.getCurrentConfPath() + "log4j.properties"); log.info(PropertyUtil.getCurrentConfPath() + "log4j.properties"); prop.put("fileRootDir", context.getString("fileRootDir","")); //批量提交Event个数 prop.put("batchUpperLimit", context.getString("batchUpperLimit","1")); //获取快照文件存放根目录 prop.put("backupFileDirPath", context.getString("backupFileDirPath", "")); // // 目录文件组合方式 0:文件log4j滚动、1:文件非log4j滚动 // // 2:日期目录+文件log4j滚动 3:日期目录+文件非log4j滚动 // prop.put("rollType", context.getString("rollType","")); // 日期目录 // prop.put("dateDir", context.getString("dateDir","")); // 文件前缀(实时文件名前缀) prop.put("filePrefix", context.getString("filePrefix","")); // 文件后缀 prop.put("fileSuffix", context.getString("fileSuffix","")); // 文件字符集 prop.put("charset", context.getString("charset", "UTF-8")); // 文件字符集 prop.put("bufferSize", context.getString("bufferSize", "4096")); //设置正则表达式匹配的文件名 prop.put("regexFileName", context.getString("regexFileName", ".*")); prop.put("clearTimeInterval", context.getString("clearTimeInterval", "3600000")); }
private static void configLog4j() { InputStream inStreamLog4j = DiameterServer.class.getClassLoader().getResourceAsStream("log4j.properties"); Properties propertiesLog4j = new Properties(); try { propertiesLog4j.load(inStreamLog4j); PropertyConfigurator.configure(propertiesLog4j); } catch (Exception e) { e.printStackTrace(); } log.debug("log4j configured"); }
private static void configLog4j() { InputStream inStreamLog4j = DiameterFirewall.class.getClassLoader().getResourceAsStream("log4j.properties"); Properties propertiesLog4j = new Properties(); try { propertiesLog4j.load(inStreamLog4j); PropertyConfigurator.configure(propertiesLog4j); } catch (Exception e) { e.printStackTrace(); } logger.debug("log4j configured"); }
public void init() { try { Properties tckProperties = new Properties(); InputStream inStreamLog4j = AbstractSctpBase.class.getResourceAsStream("/log4j.properties"); System.out.println("Input Stream = " + inStreamLog4j); Properties propertiesLog4j = new Properties(); try { propertiesLog4j.load(inStreamLog4j); PropertyConfigurator.configure(propertiesLog4j); } catch (IOException e) { e.printStackTrace(); BasicConfigurator.configure(); } logger.debug("log4j configured"); String lf = System.getProperties().getProperty(LOG_FILE_NAME); if (lf != null) { logFileName = lf; } // If already created a print writer then just use it. try { logger.addAppender(new FileAppender(new SimpleLayout(), logFileName)); } catch (FileNotFoundException fnfe) { } } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } }
public static void main(String[] args) { try { PropertyConfigurator.configure("conf/log4j.properties"); ZkServer zk = new ZkServer("D:/zk/data", "D:/zk/log", 2181); zk.start(); } catch (Exception e) { e.printStackTrace(); } }
public void init() { try { PropertyConfigurator.configure("conf/log4j.properties"); client = new ZkClient("localhost:2182"); // client.close(); } catch (Exception e) { e.printStackTrace(); } }