本文整理汇总了Java中org.springframework.util.Log4jConfigurer.initLogging方法的典型用法代码示例。如果您正苦于以下问题:Java Log4jConfigurer.initLogging方法的具体用法?Java Log4jConfigurer.initLogging怎么用?Java Log4jConfigurer.initLogging使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.Log4jConfigurer
的用法示例。
在下文中一共展示了Log4jConfigurer.initLogging方法的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: init
import org.springframework.util.Log4jConfigurer; //导入方法依赖的package包/类
public void init() {
try {
Log4jConfigurer.initLogging(location, refreshInterval);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: 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));
}
}
示例9: 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));
}
}
示例10: 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));
}
}
示例11: 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();
}
示例12: 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);
}
}
示例13: loadConfig
import org.springframework.util.Log4jConfigurer; //导入方法依赖的package包/类
public static void loadConfig(String filename) throws FileNotFoundException
{
if (filename != null)
{
LogManager.resetConfiguration();
Log4jConfigurer.initLogging(filename);
}
}
示例14: init
import org.springframework.util.Log4jConfigurer; //导入方法依赖的package包/类
/**
* 初始化log4j和Spring配置
*/
public final synchronized static void init() {
try {
Log4jConfigurer.initLogging(RmPathHelper.getWarName() + "/WEB-INF/config/log4j/log4j.properties");
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
RmBeanFactory.getBeanFactory();
}
示例15: main
import org.springframework.util.Log4jConfigurer; //导入方法依赖的package包/类
/**
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Properties properties = new Properties();
System.setProperty("project.home", ConfigUtil.filter("${project.home:.}", System.getProperties()));
String projectHome = System.getProperty("project.home");
properties.load(new FileInputStream(new File(ConfigUtil.filter("${project.home:.}", System.getProperties()), "application.properties")));
ConfigUtil.addProperties(properties);
__INIT_LOG: {
String logbackConf = System.getProperty("logback.configurationFile", "${project.home}/conf/logback.xml");
logbackConf = ConfigUtil.filter(logbackConf, System.getProperties());
File logbackFile = new File(logbackConf);
if (logbackFile.exists()) {
System.out.println("Log system load configuration form " + logbackConf);
System.setProperty("logback.configurationFile", logbackConf);
break __INIT_LOG;
}
String log4jConf = System.getProperty("log4j.configuration", "${project.home}/conf/log4j.xml");
log4jConf = ConfigUtil.filter(log4jConf, System.getProperties());
File log4jFile = new File(log4jConf);
if (!log4jFile.exists()) {
log4jConf = System.getProperty("log4j.configuration", "${project.home}/conf/log4j.properties");
log4jConf = ConfigUtil.filter(log4jConf, System.getProperties());
log4jFile = new File(log4jConf);
}
if (log4jFile.exists()) {
try {
System.setProperty("log4j.configuration", log4jConf);
System.out.println("Log system load configuration form " + log4jConf);
Log4jConfigurer.initLogging(log4jConf, 30 * 1000);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
break __INIT_LOG;
} catch (FileNotFoundException e1) {
// INGORE
}
}
}
VenusJettyServer server = new VenusJettyServer();
server.setContextPath(ConfigUtil.filter("${webapp.context:/}").toString());
server.setWebapp(ConfigUtil.filter("${webapp.dir:" + projectHome + "/webapp}").toString());
server.setPort(Integer.parseInt(ConfigUtil.filter("${webapp.port:8080}").toString()));
server.start();
}