本文整理汇总了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());
}
}
示例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);
}
示例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);
}
}
示例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..完毕");
}
示例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);
}
}
}
示例6: init
import org.springframework.util.Log4jConfigurer; //导入依赖的package包/类
public void init() {
try {
Log4jConfigurer.initLogging(location, refreshInterval);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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();
}
示例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);
}
}