Example usage for io.netty.util.internal.logging Slf4JLoggerFactory Slf4JLoggerFactory

List of usage examples for io.netty.util.internal.logging Slf4JLoggerFactory Slf4JLoggerFactory

Introduction

In this page you can find the example usage for io.netty.util.internal.logging Slf4JLoggerFactory Slf4JLoggerFactory.

Prototype

@Deprecated
public Slf4JLoggerFactory() 

Source Link

Usage

From source file:cn.wantedonline.puppy.Bootstrap.java

License:Apache License

private void initEnv() {
    long begin = System.currentTimeMillis();
    //?Netty/*from  w w  w.  j a va  2 s .  com*/
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    //????
    try {
        statisticManager.readStatisticData();
    } catch (Throwable t) {//???????
        log.error("read statistic data error, error info{}", t);
    }
    System.out.println("------------------------------> "
            + (System.currentTimeMillis() - begin) + "MS");
}

From source file:com.uber.tchannel.BaseTest.java

License:Open Source License

public static void setupLogger() {

    Properties properties = new Properties();
    properties.setProperty("log4j.rootLogger", "WARN, A1");
    properties.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender");
    properties.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout");
    properties.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-4r [%t] %-5p %c %x - %m%n");
    PropertyConfigurator.configure(properties);

    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
}

From source file:com.uber.tchannel.benchmarks.LargePayloadBenchmark.java

License:Open Source License

@Setup(Level.Trial)
public void setup() throws Exception {
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    BasicConfigurator.configure();//from  w ww  .j  a  v a  2  s .  co m
    LogManager.getRootLogger().setLevel(org.apache.log4j.Level.INFO);

    this.host = InetAddress.getByName("127.0.0.1");
    this.channel = new TChannel.Builder("ping-server").setServerHost(host).setBossGroup(bossGroup)
            .setChildGroup(childGroup).build();
    channel.makeSubChannel("ping-server").register("ping", new PingDefaultRequestHandler());
    channel.listen();
    this.port = this.channel.getListeningPort();

    this.client = new TChannel.Builder("ping-client")
            // .setResetOnTimeoutLimit(100)
            .setClientMaxPendingRequests(200000).setBossGroup(bossGroup).setChildGroup(childGroup).build();
    this.subClient = this.client.makeSubChannel("ping-server");
    this.client.listen();

    byte[] buf = new byte[60 * 1024];
    new Random().nextBytes(buf);
    payload = Unpooled.wrappedBuffer(buf);
}

From source file:com.uber.tchannel.benchmarks.PingPongMultiServerBenchmark.java

License:Open Source License

@Setup(Level.Trial)
public void setup() throws Exception {
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    BasicConfigurator.configure();/* w  w  w.jav  a  2s.c o m*/
    LogManager.getRootLogger().setLevel(org.apache.log4j.Level.INFO);

    createServers();
    this.client = new TChannel.Builder("ping-client").setClientMaxPendingRequests(150000)
            .setBossGroup(bossGroup).setChildGroup(childGroup).build();
    this.subClient = this.client.makeSubChannel("ping-server");
    List<InetSocketAddress> peers = new ArrayList<>();
    List<Connection> conns = new ArrayList<>();
    for (int i = 0; i < connections; i++) {
        TChannel server = servers.get(i);
        InetSocketAddress address = new InetSocketAddress(server.getHost(), server.getListeningPort());
        peers.add(address);
        conns.add(subClient.getPeerManager().connectTo(address));
    }

    this.subClient.setPeers(peers);
    for (Connection conn : conns) {
        conn.waitForIdentified(120000);
    }
}

From source file:com.uber.tchannel.benchmarks.PingPongServerBenchmark.java

License:Open Source License

@Setup(Level.Trial)
public void setup() throws Exception {
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    BasicConfigurator.configure();/*  w  w  w  .j  a v a 2  s  . c  o  m*/
    LogManager.getRootLogger().setLevel(org.apache.log4j.Level.INFO);

    this.host = InetAddress.getByName("127.0.0.1");
    this.channel = new TChannel.Builder("ping-server").setServerHost(host).setBossGroup(bossGroup)
            .setChildGroup(childGroup).build();
    channel.makeSubChannel("ping-server").register("ping", new PingDefaultRequestHandler());
    channel.listen();
    this.port = this.channel.getListeningPort();

    this.client = new TChannel.Builder("ping-client")
            // .setResetOnTimeoutLimit(100)
            .setClientMaxPendingRequests(100000).setBossGroup(bossGroup).setChildGroup(childGroup).build();
    this.subClient = this.client.makeSubChannel("ping-server");
    this.client.listen();
}

From source file:com.uber.tchannel.hyperbahn.api.BaseTest.java

License:Open Source License

public static void setupLogger() {
    Properties properties = new Properties();
    properties.setProperty("log4j.rootLogger", "WARN, A1");
    properties.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender");
    properties.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout");
    properties.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-4r [%t] %-5p %c %x - %m%n");
    PropertyConfigurator.configure(properties);

    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
}

From source file:com.whizzosoftware.hobson.bootstrap.Activator.java

License:Open Source License

@Override
public void init(BundleContext context, DependencyManager manager) throws Exception {
    logger.info("Hobson core is starting");

    // set the Netty log factory
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());

    // create all OSGi managers
    createManagers(manager);/*from  ww  w .  jav  a  2s  . co m*/

    // create the dependency injector for all REST resources
    Guice.createInjector(new SelfInjectingServerResourceModule(), new HobsonManagerModule());

    // Create the Restlet server
    Engine engine = Engine.getInstance();
    engine.setLoggerFacade(new Slf4jLoggerFacade());
    component.getClients().add(Protocol.CLAP);
    component.getLogService().setEnabled(false);

    // listen for the HubManager to be published
    hubManagerTracker = new ServiceTracker(context, HubManager.class.getName(), null) {
        @Override
        public Object addingService(ServiceReference ref) {
            HubManager hubManager = (HubManager) context.getService(ref);

            // start up the HTTP/HTTPS server
            List<Protocol> protocols = new ArrayList<>();
            Server server;
            if (Boolean.parseBoolean(System.getProperty("useSSL", "false"))) {
                Engine.getInstance().getRegisteredServers().add(new HttpsServerHelper(null));
                protocols.add(Protocol.HTTPS);
                server = new Server(null, protocols, null, 8183, null,
                        "org.restlet.ext.jetty.HttpsServerHelper");
                component.getServers().add(server);
                Series<Parameter> parameters = server.getContext().getParameters();
                parameters.add("keystorePath", "conf/keystore.jks");
                parameters.add("keystorePassword", "ngZiCkr24ZnbVG");
                parameters.add("keystoreType", "JKS");
                parameters.add("keyPassword", "ngZiCkr24ZnbVG");
            } else {
                Engine.getInstance().getRegisteredServers().add(new HttpServerHelper(null));
                protocols.add(Protocol.HTTP);
                server = new Server(null, protocols, null, 8182, null,
                        "org.restlet.ext.jetty.HttpServerHelper");
                component.getServers().add(server);
            }

            try {
                // register the root application
                registerRestletApplication(new RootApplication(), "");

                // register the REST API application
                registerRestletApplication(new ApiV1Application(new HobsonVerifier(hubManager)),
                        ApiV1Application.PATH);

                // register the setup wizard
                registerRestletApplication(new SetupApplication(), "/setup");

                // check for any existing registered Restlet applications
                ServiceReference[] refs = context.getServiceReferences(Application.class.getName(), null);
                if (refs != null) {
                    for (ServiceReference ref2 : refs) {
                        registerRestletApplication(ref2);
                    }
                }

                // start the Restlet component
                component.start();

                // determine web app URL prefix
                String consoleURI;
                if (System.getProperty("useSSL") != null) {
                    consoleURI = "https://localhost:8183";
                } else {
                    consoleURI = "http://localhost:8182";
                }
                if (hubManager.isSetupWizardComplete(UserUtil.DEFAULT_USER, UserUtil.DEFAULT_HUB)) {
                    consoleURI += "/console/index.html";
                } else {
                    consoleURI += "/setup/index.html";
                }

                // launch a browser
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().browse(new URI(consoleURI));
                } else {
                    System.out.println("Hobson is now available at " + consoleURI);
                }
            } catch (Exception e) {
                logger.error("Error starting REST API server", e);
            }

            return null;
        }
    };
    hubManagerTracker.open();

    // start listening for new Restlet applications
    applicationTracker = new ServiceTracker(context, Application.class.getName(), null) {
        @Override
        public Object addingService(ServiceReference ref) {
            logger.debug("Detected addition of Restlet service: {}", ref);
            registerRestletApplication(ref);
            return super.addingService(ref);
        }

        @Override
        public void removedService(ServiceReference ref, Object service) {
            logger.debug("Detected removal of Restlet service: {}", service);
            if (service instanceof Application) {
                unregisterRestletApplication((Application) service);
            } else {
                logger.debug("Unknown Restlet service unregistered: {}", service);
            }
            super.removedService(ref, service);
        }
    };
    applicationTracker.open();

    // wait for ConfigurationAdmin to become available to start advertising presence
    presenceTracker = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null) {
        @Override
        public Object addingService(ServiceReference serviceRef) {
            ServiceReference ref = context.getServiceReference(ConfigurationAdmin.class.getName());
            if (ref != null) {
                // start advertisements
                ConfigurationAdmin configAdmin = (ConfigurationAdmin) context.getService(ref);
                startAdvertiser();
                return configAdmin;
            } else {
                return null;
            }
        }

        @Override
        public void removedService(ServiceReference ref, Object service) {
            super.removedService(ref, service);
        }
    };
    presenceTracker.open();
}

From source file:de.unipassau.isl.evs.ssh.core.network.Client.java

License:Open Source License

/**
 * Configure netty and initialize related Components.
 * Afterwards call {@link #initClient()} method to start the netty IO client asynchronously.
 *//*w w w  .ja  v  a 2s  . c  o m*/
@Override
public void init(Container container) {
    super.init(container);
    // Configure netty
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() {
        @Override
        public InternalLogger newInstance(String name) {
            return new NettyInternalLogger(name);
        }
    });
    ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION);
    // And try to connect
    isActive = true;
    initClient();
    // register BroadcastListener
    IntentFilter filter = new IntentFilter();
    filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
    filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    requireComponent(ContainerService.KEY_CONTEXT).registerReceiver(broadcastReceiver, filter);
}

From source file:de.unipassau.isl.evs.ssh.master.network.Server.java

License:Open Source License

/**
 * Init timeouts and the connection registry and start the netty IO server synchronously
 *///from w  w  w .ja v  a 2  s. c  o  m
@Override
public void init(Container container) {
    super.init(container);
    try {
        // Configure netty
        InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory() {
            @Override
            public InternalLogger newInstance(String name) {
                return new NettyInternalLogger(name);
            }
        });
        ResourceLeakDetector.setLevel(CoreConstants.NettyConstants.RESOURCE_LEAK_DETECTION);
        // Start server
        startServer();
    } catch (InterruptedException e) {
        throw new StartupException("Could not start netty server", e);
    }
}

From source file:edu.upennlib.redirect.Redirect.java

License:Apache License

public static void main(String[] args) throws Exception {
    InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
    String propFileName = args.length < 1 ? DEFAULT_PROPFILE : args[0];
    Redirect sp = new Redirect(loadProperties(propFileName));
    sp.run();/*  ww w  .j a  v  a  2s  .  c o  m*/
}