本文整理汇总了Java中org.apache.log4j.xml.DOMConfigurator.configure方法的典型用法代码示例。如果您正苦于以下问题:Java DOMConfigurator.configure方法的具体用法?Java DOMConfigurator.configure怎么用?Java DOMConfigurator.configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.log4j.xml.DOMConfigurator
的用法示例。
在下文中一共展示了DOMConfigurator.configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loading
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
@Override
public void loading() throws AlbianServiceException {
try {
Thread.currentThread().setContextClassLoader(AlbianClassLoader.getInstance());
if (KernelSetting.getAlbianConfigFilePath().startsWith("http://")) {
DOMConfigurator.configure(new URL(Path
.getExtendResourcePath(KernelSetting
.getAlbianConfigFilePath() + "log4j.xml")));
} else {
DOMConfigurator.configure(Path
.getExtendResourcePath(KernelSetting
.getAlbianConfigFilePath() + "log4j.xml"));
}
super.loading();
loggers = new ConcurrentHashMap<String, Logger>();
// logger = LoggerFactory.getLogger(ALBIAN_LOGGER);
} catch (Exception exc) {
throw new AlbianServiceException(exc.getMessage(), exc.getCause());
}
}
示例2: main
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
public static void main(final String[] args) {
final String log4jConfiguration = System.getProperties().getProperty("log4j.configuration");
if (StringUtils.isNotBlank(log4jConfiguration)) {
final String parsedConfiguration = PathUtils.clean(StringUtils.removeStart(log4jConfiguration, "file:"));
final File configFile = new File(parsedConfiguration);
if (configFile.exists()) {
DOMConfigurator.configure(parsedConfiguration);
} else {
BasicConfigurator.configure();
}
}
log.info("Starting Merge Tool");
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(final Thread thread, final Throwable throwable) {
log.error("Uncaught exception in " + thread.getName(), throwable);
}
});
final int returnCode = setupAndRun(args);
log.info("Finished running Merge Tool");
System.exit(returnCode);
}
示例3: main
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* <p>
* main.
* </p>
*
* @param args a {@link java.lang.String} object.
* @throws java.lang.Throwable if any.
*/
public static void main(final String... args) throws Throwable
{
final AppContext cfg = new AppContext(workDir());
LogManager.resetConfiguration();
DOMConfigurator.configure(cfg.log4jConfigFileName);
try
{
Funnel.sort(cfg, args);
} catch (final ParseException e)
{
System.out.println(e.getMessage());
}
System.exit(0);
}
示例4: main
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Main method for Ilves seed project.
*
* @param args the commandline arguments
* @throws Exception if exception occurs in jetty startup.
*/
public static void main(final String[] args) throws Exception {
// Configure logging.
DOMConfigurator.configure("log4j.xml");
// Construct jetty server.
final Server server = Ilves.configure(PROPERTIES_FILE_PREFIX, LOCALIZATION_BUNDLE_PREFIX, PERSISTENCE_UNIT);
// Initialize modules
Ilves.initializeModule(AuditModule.class);
Ilves.initializeModule(CustomerModule.class);
Ilves.initializeModule(ContentModule.class);
Ilves.addNavigationCategoryPage(0, "custom");
Ilves.addChildPage("custom", "comments", DefaultValoView.class);
Ilves.setPageComponent("comments", Slot.CONTENT, HelloComponent.class);
Ilves.setPageComponent("comments", Slot.FOOTER, CommentingComponent.class);
Ilves.setDefaultPage("comments");
// Start server.
server.start();
// Wait for exit of the Jetty server.
server.join();
}
示例5: SPGDayUnitTest
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Constructs a new test with the given name.
*
* @param name the name of the test
*/
public SPGDayUnitTest(String name) {
super(name);
// Load the logging configuration
BasicConfigurator.configure();
try {
DOMConfigurator.configure(new URL(System.getProperty(
"log4j.configuration")));
} catch (MalformedURLException mue) {
log.error("Unable to configure logging service from XML configuration " +
"file", mue);
}
}
示例6: configureLogging
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
protected static void configureLogging(Properties properties) {
// Init logging: Try standard log4j configuration mechanism before falling back to
// provided logging configuration
String log4jConfig = System.getProperty("log4j.configuration");
if (null == log4jConfig) {
if (properties.containsKey(PropertiesBasedServerSetupBuilder.GREENMAIL_VERBOSE)) {
DOMConfigurator.configure(GreenMailStandaloneRunner.class.getResource("/log4j-verbose.xml"));
} else {
DOMConfigurator.configure(GreenMailStandaloneRunner.class.getResource("/log4j.xml"));
}
} else {
if (log4jConfig.toLowerCase().endsWith(".xml")) {
DOMConfigurator.configure(log4jConfig);
} else {
PropertyConfigurator.configure(log4jConfig);
}
}
}
示例7: init
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public void init(Map params, File configDir)
throws MetadataProviderException {
// Call super's init method to handle basic Metadata Adapter features
super.init(params, configDir);
String logConfig = (String) params.get("log_config");
if (logConfig != null) {
File logConfigFile = new File(configDir, logConfig);
String logRefresh = (String) params.get("log_config_refresh_seconds");
if (logRefresh != null) {
DOMConfigurator.configureAndWatch(logConfigFile.getAbsolutePath(), Integer.parseInt(logRefresh) * 1000);
} else {
DOMConfigurator.configure(logConfigFile.getAbsolutePath());
}
}
logger = Logger.getLogger("LS_demos_Logger.StockQuotesMetadata");
logger.info("StockQuotesMetadataAdapter ready");
}
开发者ID:Lightstreamer,项目名称:Lightstreamer-example-MPNStockListMetadata-adapter-java,代码行数:23,代码来源:StockQuotesMetadataAdapter.java
示例8: setAppenderForLogger
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
private void setAppenderForLogger()
{
String cleanMac = settop.getLogDirectory();
if ( cleanMac == null )
{
cleanMac = "UnknownMac";
}
Map<String,String> mdcMap = new HashMap<String,String>();
mdcMap.put("SettopMac", cleanMac);
mdcMap.put("LogFileName", "RebootDetection.log");
MDC.setContextMap(mdcMap);
URL logFileUrl = getClass().getResource("/reboot-report-log4j.xml" );
DOMConfigurator.configure( logFileUrl );
rebootDetectionLogger = LoggerFactory.getLogger("RebootDetection");
}
示例9: main
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Main method for Ilves seed project.
*
* @param args the commandline arguments
* @throws Exception if exception occurs in jetty startup.
*/
public static void main(final String[] args) throws Exception {
// Configure logging.
DOMConfigurator.configure("log4j.xml");
// Construct jetty server.
final Server server = Ilves.configure(PROPERTIES_FILE_PREFIX, LOCALIZATION_BUNDLE_PREFIX, PERSISTENCE_UNIT);
// Initialize modules
Ilves.initializeModule(AuditModule.class);
Ilves.initializeModule(CustomerModule.class);
Ilves.initializeModule(ContentModule.class);
Ilves.addRootPage(0, "custom", DefaultValoView.class);
Ilves.setPageComponent("custom", Slot.CONTENT, WelcomeComponent.class);
Ilves.setPageComponent("custom", Slot.FOOTER, CommentingComponent.class);
Ilves.setDefaultPage("custom");
// Start server.
server.start();
// Wait for exit of the Jetty server.
server.join();
}
示例10: reloadConfig
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
private void reloadConfig() throws MalformedURLException, FactoryConfigurationError, BException {
String blurHome = System.getenv("BLUR_HOME");
if (blurHome != null) {
File blurHomeFile = new File(blurHome);
if (blurHomeFile.exists()) {
File log4jFile = new File(new File(blurHomeFile, "conf"), "log4j.xml");
if (log4jFile.exists()) {
LOG.info("Reseting log4j config from [{0}]", log4jFile);
LogManager.resetConfiguration();
DOMConfigurator.configure(log4jFile.toURI().toURL());
return;
}
}
}
URL url = TableAdmin.class.getResource("/log4j.xml");
if (url != null) {
LOG.info("Reseting log4j config from classpath resource [{0}]", url);
LogManager.resetConfiguration();
DOMConfigurator.configure(url);
return;
}
throw new BException("Could not locate log4j file to reload, doing nothing.");
}
示例11: loadLoggingConfig
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
/**
* Loads the embedded logging configuration (from the JAR file).
*/
private void loadLoggingConfig() {
// get a URL from the classloader for the logging configuration
URL log4jConfigUrl = ClassLoader.getSystemResource(LOG4J_CONFIG_PATH);
// if we didn't get a URL, tell the user that something went wrong
if (log4jConfigUrl == null) {
System.err.println("Unable to find logging configuration file in JAR " +
"with " + LOG4J_CONFIG_PATH + ", reverting to default configuration.");
BasicConfigurator.configure();
} else {
try {
// configure the logging service
DOMConfigurator.configure(log4jConfigUrl);
log.info("Using logging configuration from " + log4jConfigUrl);
} catch (FactoryConfigurationError e) {
System.err.println("Unable to configure logging service");
}
}
}
示例12: main
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
public static void main(String[] args) throws ClassNotFoundException, SQLException, NoSuchAuthorityCodeException,
FactoryException, TransformException, IOException {
DOMConfigurator.configure("log4j.xml");
VisualisationSettings set = new VisualisationSettings("mf.felk.cvut.cz", 5432, "visio", "geovisio", "visio",
"http://mf.felk.cvut.cz:8080/geoserver", "admin", "geovisio");
DatabaseConnection conn = new PostgisConnection(set.getDatabaseServerHost(), set.getDatabaseServerPort(),
set.getDatabaseUser(), set.getDatabasePassword(), set.getDatabaseName());
conn.connect();
KmlBuilder builder = new KmlBuilder();
// builder.addKmlItem(createPTDriverVis("tram", conn, Color.RED));
// createPTDriverVis("bus", conn,
// Color.CYAN).saveToKml("bus_drivers.kml");
// createPTDriverVis("tram", conn, Color.CYAN).saveToKml("pokus.kml");
createAgentVis("man", conn, Color.RED).saveToKml("passengers.kml");
createTaxiVis("cabs", conn, Color.GREEN).saveToKml("taxis.kml");
// builder.writeDataToFileAndCleanBuilder(new File("bus_drivers.kmz"));
conn.close();
}
示例13: testAppend
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
public static void testAppend() throws Exception{
DOMConfigurator.configure("c:/gg_test_jdbcLog.xml");
// System.setProperty( "java.library.path", "/oracle/product/9i/bin" );
long startTime = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
cat.debug("DEBUG" );
cat.info("INFO");
cat.error("ERROR");
cat.fatal("FATAL");
}
long endTime = System.currentTimeMillis();
System.out.println( "Total elapsed time was: " + (endTime - startTime) );
}
示例14: initLogging
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
public static void initLogging(ServletContext servletContext) {
if (!initialized) {
String configFileName = servletContext.getInitParameter(CONTEXT_PARAM_LOG4J_CONFIG_LOCATION);
if (null != configFileName && configFileName.length() > 0) {
configFileName = servletContext.getRealPath(configFileName);
try {
DOMConfigurator.configure(configFileName);
log.info(String.format("Log4j config file: %s", configFileName));
initialized = true;
} catch (Exception e) {
System.err.println("ERROR: Loading log4j config file: " + configFileName + ".");
System.err.println(e.getMessage());
}
}
} else {
log.info("Log4j already initialized");
}
}
示例15: testSetup
import org.apache.log4j.xml.DOMConfigurator; //导入方法依赖的package包/类
@BeforeClass
public static void testSetup() throws IOException, SQLException, DAOConfigurationException {
URL configFileResource = PostgresqlDAOTest.class.getResource("/com/ast/processserver/resources/log4j.xml");
DOMConfigurator.configure(configFileResource);
Config.loadProperties();
String dataSource = "postgresql";
DAOFactory factory = new DAOFactory(dataSource);
connection = ConnectionPoolFactory.getConnectionPool(dataSource).getConnection();
workspaceDAO = factory.getWorkspaceDao(connection);
userDao = factory.getUserDao(connection);
objectDao = factory.getItemDAO(connection);
oversionDao = factory.getItemVersionDAO(connection);
}