Exemple #1
0
 public static void initializeLogging() {
   Logger.getRootLogger().setLevel(Level.INFO);
   ConsoleAppender console = new ConsoleAppender();
   console.setWriter(new PrintWriter(System.out));
   console.setLayout(new PatternLayout("%d{ISO8601} %d %p [%t] %c - %m%n"));
   Logger.getRootLogger().addAppender(console);
 }
Exemple #2
0
  public void init() {

    ConsoleAppender console = new ConsoleAppender(); // create appender
    // configure the appender
    String PATTERN = "%d [%p|%c|%C{1}] %m%n";
    console.setLayout(new PatternLayout(PATTERN));
    console.setThreshold(Level.DEBUG);
    console.activateOptions();
    // add appender to any Logger (here is root)
    Logger.getRootLogger().addAppender(console);
    SipFactory sipFactory = null;
    sipStack = null;
    sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("gov.nist");
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "shootme");
    // You need 16 for logging traces. 32 for debug + traces.
    // Your code will limp at 32 but it is best for debugging.
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "LOG4J");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "shootmedebug.txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "shootmelog.txt");
    properties.setProperty(
        "gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());

    try {
      // Create SipStack object
      sipStack = sipFactory.createSipStack(properties);
      System.out.println("sipStack = " + sipStack);
    } catch (PeerUnavailableException e) {
      // could not find
      // gov.nist.jain.protocol.ip.sip.SipStackImpl
      // in the classpath
      e.printStackTrace();
      System.err.println(e.getMessage());
      if (e.getCause() != null) e.getCause().printStackTrace();
      System.exit(0);
    }

    try {
      headerFactory = sipFactory.createHeaderFactory();
      addressFactory = sipFactory.createAddressFactory();
      messageFactory = sipFactory.createMessageFactory();
      this.listeningPoint = sipStack.createListeningPoint("127.0.0.1", myPort, transport);

      B2BUA listener = this;

      sipProvider = sipStack.createSipProvider(listeningPoint);
      System.out.println("ws provider " + sipProvider);
      sipProvider.addSipListener(listener);

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      ex.printStackTrace();
    }
  }
Exemple #3
0
  public static void main(final String[] args) {

    // Disable log system, we want full control over what is sent to console.
    final ConsoleAppender consoleAppender = new ConsoleAppender();
    consoleAppender.activateOptions();
    consoleAppender.setLayout(new PatternLayout("%p %t %C:%M %m%n"));
    consoleAppender.setThreshold(Level.OFF);
    BasicConfigurator.configure(consoleAppender);

    // Parse the flags.
    Flags flags = new Flags().loadOpts(ZkTool.class).parse(args);

    // Check if we wish to print out help text
    if (flags.helpFlagged()) {
      flags.printHelp(System.out);
      System.out.println("Must specify one of the following options:");
      System.out.println(actionSelectingFlagNames);
      return;
    }

    checkArgumentCombinationValid(flags);

    ZkCloudname.Builder builder = new ZkCloudname.Builder();
    if (zooKeeperFlag == null) {
      builder.setDefaultConnectString();
    } else {
      builder.setConnectString(zooKeeperFlag);
    }
    try {
      cloudname = builder.build().connect();
    } catch (CloudnameException e) {
      System.err.println("Could not connect to zookeeper " + e.getMessage());
      return;
    }

    try {
      if (filePath != null) {
        handleFilepath();
      } else if (coordinateFlag != null) {
        handleCoordinateOperation();
      } else if (resolverExpression != null) {
        handleResolverExpression();
      } else if (listFlag) {
        listCoordinates();
      } else {
        System.err.println("No action specified");
      }
    } catch (Exception e) {
      System.err.println("An error occurred: " + e.getMessage());
      e.printStackTrace();
    } finally {
      cloudname.close();
    }
  }
  /* Configure the log4j appenders
   */
  static void configureLogger() {
    ConsoleAppender console = new ConsoleAppender(); // create appender
    // configure the appender
    console.setLayout(new PatternLayout(PATTERN));
    console.setThreshold(Level.ALL);
    console.activateOptions();
    // add appender to any Logger (here is root)
    log.addAppender(console);
    // This is for the rmi_server log file
    FileAppender fa = new FileAppender();
    fa.setName("FileLogger");
    fa.setFile("log/_rmi_server.log");
    fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
    fa.setThreshold(Level.ALL);
    fa.setAppend(true);
    fa.activateOptions();

    // add appender to any Logger (here is root)
    log.addAppender(fa);
    log.setAdditivity(false);
    // repeat with all other desired appenders
  }