当前位置: 首页>>代码示例>>Java>>正文


Java Log4jConfigurer类代码示例

本文整理汇总了Java中org.springframework.util.Log4jConfigurer的典型用法代码示例。如果您正苦于以下问题:Java Log4jConfigurer类的具体用法?Java Log4jConfigurer怎么用?Java Log4jConfigurer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Log4jConfigurer类属于org.springframework.util包,在下文中一共展示了Log4jConfigurer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initLogging

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * Initialize log4j, including setting the web app root system property.
 *
 * @param servletContext
 *            the current ServletContext
 * @see WebUtils#setWebAppRootSystemProperty
 */
public static void initLogging(ServletContext servletContext, Resource resource) {
    // Perform actual log4j initialization; else rely on log4j's default
    // initialization.
    try {
        String path = resource.getFile().getAbsolutePath();

        // Write log message to server log.
        servletContext.log("Initializing log4j from [" + path + "]");

        Log4jConfigurer.initLogging(path, LOG4J_REFRESH_MS);
    } catch (FileNotFoundException ex) {
        throw new IllegalArgumentException("Invalid 'log4jConfigLocation' parameter: " + ex.getMessage());
    } catch (IOException ioEx) {
        throw new IllegalArgumentException("Invalid 'log4jConfigLocation' parameter: " + ioEx.getMessage());
    }
}
 
开发者ID:gchq,项目名称:stroom-proxy,代码行数:24,代码来源:Log4jWebConfigurer.java

示例2: contextInitialized

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public void contextInitialized(ServletContextEvent sce) {
   	try {
	    Log4jConfigurer.initLogging("classpath:log4j.properties");
	} catch (FileNotFoundException e) {
	    throw new RuntimeException("Failed to start sample application.", e);
	}

	Object o = sce.getServletContext().getAttribute("JETTYSERVER_TESTMODE");
	boolean testMode = false;
	if (o != null) {
	    testMode = Boolean.valueOf((String) o);
	}
	LOG.info("Travel webapp starting up in " + (testMode ? "test" : "normal") + " mode");
	// this loads up the Spring context
	TravelServiceLocator.initialize(testMode);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:17,代码来源:TravelAppInitializeListener.java

示例3: _init_logging

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
private void _init_logging() {
	// allow for local file config
	final File loggingConfig = new File(startupDir, "logging.properties");
	final String loggingPath;
	if (loggingConfig.exists()) {
		loggingPath = "file:" + loggingConfig.getAbsolutePath();
	} else {
		loggingPath = "classpath:org/signalml/app/logging/log4j_app.properties";
	}

	try {
		Log4jConfigurer.initLogging(loggingPath);
	} catch (FileNotFoundException ex) {
		System.err.println("Critical error: no logging configuration");
		System.exit(1);
	}
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:18,代码来源:SvarogApplication.java

示例4: reloadContext

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * 快速重新启动Application
 * @see 通常用Main函数启动JettyServer后,若改动项目的代码,那就需要停止再启动Jetty
 * @see 虽免去了Tomcat重新打包几十兆的消耗,但比起PHP完全不用重启来说还是慢,特别是关闭,启动一个新的JVM,消耗不小
 * @see 所以我们可以在Main()中捕捉到回车后调用此函数,即可重新载入应用(包括Spring配置文件)
 * @param server    当前运行的JettyServer实例
 * @param classPath 当前运行的Web应用的classpath
 */
@SuppressWarnings("unused")
private static /*synchronized*/ void reloadContext(Server server, String classPath) throws Exception{
	WebAppContext context = (WebAppContext)server.getHandler();
	System.out.println("Application reloading..开始");
	context.stop();
	WebAppClassLoader classLoader = new WebAppClassLoader(context);
	classLoader.addClassPath(classPath);
	context.setClassLoader(classLoader);
	//根据给定的配置文件初始化日志配置(否则应用重载后日志输出组件就会失效)
	Log4jConfigurer.initLogging(classPath + "/log4j.properties");
	context.start();
	System.out.println("Application reloading..完毕");
}
 
开发者ID:v5java,项目名称:demo-cas-server-web,代码行数:22,代码来源:JettyBootStrap.java

示例5: shutdownLogging

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * Shut down log4j, properly releasing all file locks
 * and resetting the web app root system property.
 * @param servletContext the current ServletContext
 * @see WebUtils#removeWebAppRootSystemProperty
 */
public static void shutdownLogging(ServletContext servletContext) {
	servletContext.log("Shutting down log4j");
	try {
		Log4jConfigurer.shutdownLogging();
	}
	finally {
		// Remove the web app root system property.
		if (exposeWebAppRoot(servletContext)) {
			WebUtils.removeWebAppRootSystemProperty(servletContext);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Log4jWebConfigurer.java

示例6: init

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public void init() {
    try {
        Log4jConfigurer.initLogging(location, refreshInterval);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}
 
开发者ID:minotaursu,项目名称:profilerAop,代码行数:8,代码来源:Log4jConfigListener.java

示例7: log4j

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
@Bean(name = "log4jInitialization")
public MethodInvoker log4j() {
    MethodInvokingFactoryBean methodInvoker = new MethodInvokingFactoryBean();
    methodInvoker.setTargetClass(Log4jConfigurer.class);
    methodInvoker.setTargetMethod("initLogging");
    methodInvoker.setArguments(getLog4jArgs());
    return methodInvoker;
}
 
开发者ID:dlcs,项目名称:elucidate-server,代码行数:9,代码来源:ServicesConfig.java

示例8: setLog4jConfigLocation

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public void setLog4jConfigLocation(String log4jConfigLocation) {
    this.log4jConfigLocation = log4jConfigLocation;
    try {
        Log4jConfigurer.initLogging(log4jConfigLocation);
    } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:9,代码来源:RuntimeLog4jConfigurer.java

示例9: contextDestroyed

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
@Override
public void contextDestroyed(ServletContextEvent sce) {
    LOG.info("Shutting down Kuali Rice...");
    if (context != null) {
        context.close();
    }
    LOG.info("...completed shutdown of Kuali Rice.");
    Log4jConfigurer.shutdownLogging();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:KualiInitializeListener.java

示例10: loadConfiguration

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
protected void loadConfiguration(String location, LogFile logFile) {
	Assert.notNull(location, "Location must not be null");
	if (logFile != null) {
		logFile.applyToSystemProperties();
	}
	try {
		Log4jConfigurer.initLogging(location);
	}
	catch (Exception ex) {
		throw new IllegalStateException(
				"Could not initialize Log4J logging from " + location, ex);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:14,代码来源:Log4JLoggingSystem.java

示例11: AbstractTestng

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * 无参构造方法,初始化log4j
 */
public AbstractTestng() {
    try {
        Log4jConfigurer.initLogging("classpath:log/log4j.xml", 60000);
    }
    catch (FileNotFoundException e) {
        LOGGER.info(ExceptionUtils.getStackTrace(e));
    }
}
 
开发者ID:owen-chen,项目名称:crawl-center,代码行数:12,代码来源:AbstractTestng.java

示例12: AbstractTestng

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * constructor
 */
public AbstractTestng() {
    try {
        Log4jConfigurer.initLogging("classpath:log/log4j.xml", 60000);
    }
    catch (FileNotFoundException e) {
        LOGGER.info(ExceptionUtils.getStackTrace(e));
    }
}
 
开发者ID:owen-chen,项目名称:crawl-center,代码行数:12,代码来源:AbstractTestng.java

示例13: AbstractTestng

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
/**
 * construct
 */
public AbstractTestng() {
    try {
        Log4jConfigurer.initLogging("classpath:log/log4j.xml", 60000);
    }
    catch (FileNotFoundException e) {
        LOGGER.info(ExceptionUtils.getStackTrace(e));
    }
}
 
开发者ID:owen-chen,项目名称:crawl-center,代码行数:12,代码来源:AbstractTestng.java

示例14: main

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public static void main(String[] args) throws TddlException, SQLException, FileNotFoundException {
    Log4jConfigurer.initLogging("src/main/resources/log4j.properties");

    TDataSource ds = new TDataSource();

    // 设置默认db(ob)
    ds.setAppName("DEV_DPS_APP");
    ds.setTopologyFile("tddl-topology-dps.xml");
    ds.setRuleFile("tddl-rule-dps-nonmysql.xml");

    // 设置simba2的mysql
    App subApp = new App();
    subApp.setAppName("DAILY_SOLAR_MERCURY_APP");
    subApp.setRuleFile("tddl-rule-dps-simba2-mysql.xml");
    ds.addSubApp(subApp);

    // 添加subway的mysql
    subApp = new App();
    subApp.setAppName("DEV_SUBWAY_MYSQL");
    subApp.setRuleFile("tddl-rule-dps-subway-mysql.xml");
    ds.addSubApp(subApp);

    Map cp = new HashMap();
    cp.put("ALLOW_TEMPORARY_TABLE", "True");
    cp.put(ConnectionProperties.TEMP_TABLE_DIR, ".\\temp\\");
    cp.put(ConnectionProperties.TEMP_TABLE_CUT_ROWS, false);
    cp.put(ConnectionProperties.TEMP_TABLE_MAX_ROWS, 1000);
    ds.setConnectionProperties(cp);

    ds.init();
    System.out.println("init done");

    // subway_adgroup_list.sql
    // solar_adgroup_list.sql
    String sql = SqlFileUtil.getSql("replace.txt");
    // sql = SqlFileUtil.getSql("solar_adgroup_list.sql");
    Connection conn = ds.getConnection();
    {
        PreparedStatement ps = conn.prepareStatement(sql);
        long start = System.currentTimeMillis();
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            StringBuilder sb = new StringBuilder();
            int count = rs.getMetaData().getColumnCount();
            for (int i = 1; i <= count; i++) {

                String key = rs.getMetaData().getColumnLabel(i);
                Object val = rs.getObject(i);
                sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
            }
            System.out.println(sb.toString());
        }
        System.out.println("done " + (System.currentTimeMillis() - start));
        rs.close();
        ps.close();
    }

    conn.close();
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:60,代码来源:Simba2Sample.java

示例15: restoreDefaults

import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public static void restoreDefaults() throws Exception {
    registryManager.removeAllRegistryEntries();
    LogManager.resetConfiguration();

    try {
        String logFile = CarbonUtils.getCarbonConfigDirPath()
                + RegistryConstants.PATH_SEPARATOR + "log4j.properties";
        Log4jConfigurer.initLogging(logFile);
    } catch (FileNotFoundException e) {
        String msg = "Cannot restore default logging configuration."
                + " log4j.properties file is not found in the classpath";
        throw new LogViewerException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:15,代码来源:LoggingUtil.java


注:本文中的org.springframework.util.Log4jConfigurer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。