Search in sources :

Example 1 with Log4JLogger

use of org.apache.ignite.logger.log4j.Log4JLogger in project ignite by apache.

the class HadoopExternalProcessStarter method logger.

/**
 * @param outputDir Directory for process output.
 * @return Logger.
 */
private IgniteLogger logger(final File outputDir) {
    final URL url = U.resolveIgniteUrl(DFLT_LOG4J_CONFIG);
    Log4JLogger logger;
    try {
        logger = url != null ? new Log4JLogger(url) : new Log4JLogger(true);
    } catch (IgniteCheckedException e) {
        System.err.println("Failed to create URL-based logger. Will use default one.");
        e.printStackTrace();
        logger = new Log4JLogger(true);
    }
    logger.updateFilePath(new IgniteClosure<String, String>() {

        @Override
        public String apply(String s) {
            return new File(outputDir, args.childProcId + ".log").getAbsolutePath();
        }
    });
    return logger;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) File(java.io.File) URL(java.net.URL)

Example 2 with Log4JLogger

use of org.apache.ignite.logger.log4j.Log4JLogger in project ignite by apache.

the class GridifySingleSplitLoadTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration() throws Exception {
    IgniteConfiguration cfg = super.getConfiguration();
    /* Uncomment following code if you start it manually. */
    CommunicationSpi commSpi = new TcpCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    DiscoverySpi discoSpi = new TcpDiscoverySpi();
    cfg.setDiscoverySpi(discoSpi);
    /*
         */
    @SuppressWarnings("TypeMayBeWeakened") Log4JLogger log = (Log4JLogger) cfg.getGridLogger();
    log.getLogger("org.apache.ignite").setLevel(Level.INFO);
    return cfg;
}
Also used : CommunicationSpi(org.apache.ignite.spi.communication.CommunicationSpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) DiscoverySpi(org.apache.ignite.spi.discovery.DiscoverySpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with Log4JLogger

use of org.apache.ignite.logger.log4j.Log4JLogger in project ignite by apache.

the class TcpRouterMultiNodeSelfTest method routerConfiguration.

/**
 * @param i Number of router. Used to avoid configuration conflicts.
 * @return Router configuration.
 * @throws IgniteCheckedException If failed.
 */
private GridTcpRouterConfiguration routerConfiguration(int i) throws IgniteCheckedException {
    GridTcpRouterConfiguration cfg = new GridTcpRouterConfiguration();
    cfg.setHost(HOST);
    cfg.setPort(ROUTER_TCP_PORT_BASE + i);
    cfg.setPortRange(0);
    cfg.setServers(Collections.singleton(HOST + ":" + REST_TCP_PORT_BASE));
    cfg.setLogger(new Log4JLogger(ROUTER_LOG_CFG));
    return cfg;
}
Also used : Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger)

Example 4 with Log4JLogger

use of org.apache.ignite.logger.log4j.Log4JLogger in project ignite by apache.

the class CacheStoreHelper method createCacheStore.

/**
 */
public static CacheStore createCacheStore(String cacheName, Resource persistenceSettings, DataSource conn, CacheStoreSession session, Logger log) {
    CassandraCacheStore<Integer, Integer> cacheStore = new CassandraCacheStore<>(conn, new KeyValuePersistenceSettings(persistenceSettings), Runtime.getRuntime().availableProcessors());
    try {
        Field sesField = CassandraCacheStore.class.getDeclaredField("storeSes");
        Field logField = CassandraCacheStore.class.getDeclaredField("log");
        sesField.setAccessible(true);
        logField.setAccessible(true);
        sesField.set(cacheStore, session != null ? session : new TestCacheSession(cacheName));
        logField.set(cacheStore, new Log4JLogger(log));
    } catch (Throwable e) {
        throw new RuntimeException("Failed to initialize test Ignite cache store", e);
    }
    return cacheStore;
}
Also used : Field(java.lang.reflect.Field) KeyValuePersistenceSettings(org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) CassandraCacheStore(org.apache.ignite.cache.store.cassandra.CassandraCacheStore)

Example 5 with Log4JLogger

use of org.apache.ignite.logger.log4j.Log4JLogger in project ignite by apache.

the class CassandraHelper method startEmbeddedCassandra.

/**
 */
public static void startEmbeddedCassandra(Logger log) {
    ClassLoader clsLdr = CassandraHelper.class.getClassLoader();
    URL url = clsLdr.getResource(EMBEDDED_CASSANDRA_YAML);
    embeddedCassandraBean = new CassandraLifeCycleBean();
    embeddedCassandraBean.setCassandraConfigFile(url.getFile());
    try {
        Field logField = CassandraLifeCycleBean.class.getDeclaredField("log");
        logField.setAccessible(true);
        logField.set(embeddedCassandraBean, new Log4JLogger(log));
    } catch (Throwable e) {
        throw new RuntimeException("Failed to initialize logger for CassandraLifeCycleBean", e);
    }
    embeddedCassandraBean.onLifecycleEvent(LifecycleEventType.BEFORE_NODE_START);
}
Also used : Field(java.lang.reflect.Field) Log4JLogger(org.apache.ignite.logger.log4j.Log4JLogger) URL(java.net.URL)

Aggregations

Log4JLogger (org.apache.ignite.logger.log4j.Log4JLogger)7 Field (java.lang.reflect.Field)2 URL (java.net.URL)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 File (java.io.File)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 CassandraCacheStore (org.apache.ignite.cache.store.cassandra.CassandraCacheStore)1 KeyValuePersistenceSettings (org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings)1 CommunicationSpi (org.apache.ignite.spi.communication.CommunicationSpi)1 DiscoverySpi (org.apache.ignite.spi.discovery.DiscoverySpi)1