/** Aktiviert das Logging zum Level FINEST. */
  private static void activateFinestLogging() {
    Handler[] handlers;
    ConsoleHandler consoleHandler;
    Logger rootLogger, archiLogger;

    rootLogger = Logger.getLogger("");
    archiLogger = Logger.getLogger("de.unistuttgart.architeuthis");

    // log-Level für alle Logger von Architeuthis setzen
    archiLogger.setLevel(Level.FINEST);

    // der DefaultHandler hängt am root-Logger
    handlers = rootLogger.getHandlers();

    // einen ConsoleHandler finden:
    consoleHandler = null;
    for (int i = 0; i < handlers.length; i++) {
      if (handlers[i] instanceof ConsoleHandler) {
        consoleHandler = (ConsoleHandler) handlers[i];
      }
    }

    // Wenn kein ConsoleHandler am root-Logger vorhanden ist, einen
    // anhängen.
    if (consoleHandler == null) {
      consoleHandler = new java.util.logging.ConsoleHandler();
      Logger.getLogger("").addHandler(consoleHandler);
    }

    consoleHandler.setLevel(Level.FINEST);
  }
Ejemplo n.º 2
0
  public static void main(String args[]) {
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINEST);

    JavaLN l = new JavaLN();
    l.setLevel(Level.FINEST);
    l.addHandler(ch);
    l.setUseParentHandlers(false);

    l.info(l.toString());
    l.severe("this is a test");
    l.entering("not", "needed"); // check for call to base class
    l.entering();
    l.entering(new Integer(10));
    l.entering(args);
    l.entering(new Object[] {new Integer(1), "one"});
    l.exiting();
    l.exiting("exiting");
    l.throwing(new Throwable("Throwable message"));

    JavaLN m = new JavaLN("one");
    m.severe(m.toString());
    m.severe("this is another test");

    JavaLN n = new JavaLN("two", null);
    n.severe(n.toString());
    n.severe("this is a third test");
    n.warning(new Throwable("this is a test"));
  }
Ejemplo n.º 3
0
 {
   logger.setUseParentHandlers(false);
   logger.setLevel(Level.INFO);
   ConsoleHandler handler = new ConsoleHandler();
   handler.setLevel(Level.INFO);
   logger.addHandler(handler);
 }
Ejemplo n.º 4
0
  /** Sets up the file logging for debugging purposes. */
  private static void setUpLogger() {
    try {
      LogManager.getLogManager().reset();
      logger.setUseParentHandlers(false);

      // Log file
      FileHandler loggingFileHandler = new FileHandler("./log" + playerNumber + ".log");
      loggingFileHandler.setLevel(Level.ALL);

      // Console logging
      ConsoleHandler loggingConsoleHandler = new ConsoleHandler();
      loggingConsoleHandler.setLevel(Level.OFF);

      // Remove old handlers
      Handler[] handlers = Logger.getGlobal().getHandlers();

      for (Handler handler : handlers) {
        Logger.getGlobal().removeHandler(handler);
      }

      // Add logging handlers
      logger.addHandler(loggingFileHandler);
      logger.addHandler(loggingConsoleHandler);

      System.setProperty(
          "java.util.logging.SimpleFormatter.format",
          "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s %4$s: %5$s%n");
      SimpleFormatter simpleFormatter = new SimpleFormatter();
      loggingFileHandler.setFormatter(simpleFormatter);

      logger.setLevel(Level.ALL);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 5
0
 /** Configure CB4J logger. */
 private void configureCB4JLogger() {
   logger.setUseParentHandlers(false);
   ConsoleHandler consoleHandler = new ConsoleHandler();
   consoleHandler.setFormatter(new LogFormatter());
   if (logger.getHandlers().length == 0) {
     logger.addHandler(consoleHandler);
   }
 }
Ejemplo n.º 6
0
 @BeforeClass
 public static void setUpClass() throws Exception {
   LogManager.getLogManager().reset();
   Logger.getLogger("").setLevel(Level.ALL);
   ConsoleHandler handler = new ConsoleHandler();
   handler.setLevel(Level.ALL);
   Logger.getLogger("").addHandler(handler);
 }
Ejemplo n.º 7
0
  static {
    LOGGER.setLevel(LOG_LEVEL);

    ConsoleHandler handler = new ConsoleHandler();
    // PUBLISH this level
    handler.setLevel(LOG_LEVEL);
    LOGGER.addHandler(handler);
  }
Ejemplo n.º 8
0
 public static void main(String[] args) {
   String inputFilename = "";
   String version = "";
   for (int i = 0; i < args.length; i++) {
     if (args[i].equals("-i")) {
       if (i == args.length - 1) {
         printUsage();
         System.exit(3);
       }
       inputFilename = args[i + 1];
     }
     if (args[i].equals("-v")) {
       if (i == args.length - 1) {
         printUsage();
         System.exit(3);
       }
       version = args[i + 1];
     }
     if (args[i].equals("-h")) {
       printUsage();
       System.exit(0);
     }
   }
   LOGGER.setLevel(Level.CONFIG);
   LOGGER.setUseParentHandlers(false);
   ConsoleHandler logConsole = new ConsoleHandler();
   logConsole.setLevel(Level.CONFIG);
   LOGGER.addHandler(logConsole);
   MyLogFormatter formatter = new MyLogFormatter();
   logConsole.setFormatter(formatter);
   /*
   try {
   	FileHandler logFile = new FileHandler("serverwiz2.%u.%g.log",20000,2,true);
   	LOGGER.addHandler(logFile);
   	logFile.setFormatter(formatter);
   	logFile.setLevel(Level.CONFIG);
   } catch (IOException e) {
   	System.err.println("Unable to create logfile");
   	System.exit(3);
   }
   */
   LOGGER.config("======================================================================");
   LOGGER.config("ServerWiz2 Starting...");
   TargetWizardController tc = new TargetWizardController();
   SystemModel systemModel = new SystemModel();
   MainDialog view = new MainDialog(null);
   tc.setView(view);
   tc.setModel(systemModel);
   systemModel.addPropertyChangeListener(tc);
   view.setController(tc);
   if (!inputFilename.isEmpty()) {
     view.mrwFilename = inputFilename;
   }
   view.open();
   // d.dispose();
 }
Ejemplo n.º 9
0
  // Use custom string format for logger.
  public static Logger setLogger(Logger logger) {
    ShortFormatter formatter = new ShortFormatter();
    ConsoleHandler handler = new ConsoleHandler();

    logger.setUseParentHandlers(false);
    handler.setFormatter(formatter);
    logger.addHandler(handler);

    return logger;
  }
Ejemplo n.º 10
0
  static {
    // uncomment to turn up logging

    java.util.logging.ConsoleHandler handler = new java.util.logging.ConsoleHandler();
    handler.setLevel(java.util.logging.Level.FINE);

    org.geotools.util.logging.Logging.getLogger("org.geotools.data.solr")
        .setLevel(java.util.logging.Level.FINE);
    org.geotools.util.logging.Logging.getLogger("org.geotools.data.solr").addHandler(handler);
  }
Ejemplo n.º 11
0
 private static final Logger createLogger() {
   final Logger logger = Logger.getLogger(Log.class.getName());
   logger.setLevel(Level.INFO);
   final ConsoleHandler ch = new ConsoleHandler();
   ch.setLevel(Level.ALL);
   ch.setFormatter(new LogFormatter());
   logger.addHandler(ch);
   logger.setUseParentHandlers(false);
   return logger;
 }
  public ToRobundle(List<String> files, String out) throws Exception {

    Logger logger = Logger.getLogger("");
    // logger.setLevel(Level.FINER);
    ConsoleHandler console = new ConsoleHandler();
    console.setLevel(Level.FINEST);
    logger.addHandler(console);
    Logger.getLogger("org.researchobject").setLevel(Level.FINEST);

    for (String f : files) {
      Path file = Paths.get(f);
      convert(file);
    }
  }
Ejemplo n.º 13
0
  public static void main(String[] args) {
    //		GatewayServer.turnAllLoggingOn();
    Logger logger = Logger.getLogger("py4j");
    logger.setLevel(Level.ALL);
    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.FINEST);
    logger.addHandler(handler);
    System.out.println("Starting");

    SharedRunnable sharedRunnable = new SharedRunnable();
    Thread thread = new Thread(sharedRunnable, "SharedRunnable");
    thread.setDaemon(true);
    thread.start();

    EntryPoint entryPoint0 = new EntryPoint(0, sharedRunnable);
    ClientServer clientServer0 = new ClientServer(entryPoint0);
    // Wait for Python side to shut down Java side
    clientServer0.startServer(true);

    // TODO: Refactor with Py4J Pull 204
    // Start the second client server on default + 10 port, the rest of the
    // arguments are the same
    EntryPoint entryPoint1 = new EntryPoint(1, sharedRunnable);
    ClientServer clientServer1 =
        new ClientServer(
            GatewayServer.DEFAULT_PORT + 2,
            GatewayServer.defaultAddress(),
            GatewayServer.DEFAULT_PYTHON_PORT + 2,
            GatewayServer.defaultAddress(),
            GatewayServer.DEFAULT_CONNECT_TIMEOUT,
            GatewayServer.DEFAULT_READ_TIMEOUT,
            ServerSocketFactory.getDefault(),
            SocketFactory.getDefault(),
            entryPoint1);
    // Wait for Python side to shut down Java side
    clientServer1.startServer(true);

    // Shut down after 5 seconds
    // clientServer.startServer(true);
    // try {
    // Thread.currentThread().sleep(5000);
    // } catch (Exception e) {
    // e.printStackTrace();
    // }
    // clientServer.shutdown();
    //
    // System.out.println("Stopping");
  }
Ejemplo n.º 14
0
 static {
   // set up logger when AtomicWords is statically initialized
   logger.setUseParentHandlers(false);
   ConsoleHandler consoleHandler = new ConsoleHandler();
   consoleHandler.setLevel(Level.SEVERE);
   logger.addHandler(consoleHandler);
   try {
     FileHandler fileHandler = new FileHandler("atomic-words%u.log");
     fileHandler.setLevel(Level.INFO);
     fileHandler.setFormatter(new SimpleFormatter());
     logger.addHandler(fileHandler);
   } catch (IOException e) {
     logger.log(Level.SEVERE, "Can not open log file, file logging disabled!", e);
   }
   logger.fine("Finished setting up logger");
 }
  public static void main(String[] args) {
    // 只有严重信息会输出出来
    logger.setLevel(Level.OFF);

    ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(Level.ALL);
    logger.addHandler(consoleHandler);

    logger.severe("严重信息");
    logger.warning("警告信息");
    logger.info("一般信息");
    logger.config("配置信息");
    logger.fine("细微信息");
    logger.finer("更细微信息");
    logger.finest("最细微信息");
  }
Ejemplo n.º 16
0
  public static void main(String[] args) {
    final File swapDir = new File("swap");
    swapDir.mkdir();
    final Logger logger = Logger.getAnonymousLogger();
    final ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(Level.ALL);
    logger.addHandler(consoleHandler);
    logger.setLevel(Level.ALL);
    final DefaultSwapSpace swapSpace = new DefaultSwapSpace(swapDir, logger);
    final SwappingTileCache tileCache = new SwappingTileCache(64 * M, swapSpace);
    JAI.getDefaultInstance().setTileCache(tileCache);

    RenderedImage sourceImage;
    if (args.length == 0) {
      sourceImage = DFTTestMain.createTestImage(512, 512);
    } else {
      sourceImage = FileLoadDescriptor.create(args[0], null, false, null);
    }

    sourceImage = DFTConvolveRIF.toFloat(sourceImage, null);

    BorderExtender extender = BorderExtender.createInstance(BorderExtender.BORDER_COPY);
    RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, extender);
    KernelJAI kernel = createBlurrKernel(33);
    RenderedOp convolvedImage = ConvolveDescriptor.create(sourceImage, kernel, hints);
    RenderedOp dftConvolvedImage = DFTConvolveDescriptor.create(sourceImage, kernel, null, hints);
    RenderedOp deltaImage =
        MultiplyConstDescriptor.create(
            SubtractDescriptor.create(convolvedImage, dftConvolvedImage, null),
            new double[] {2},
            null);
    showImage(sourceImage, "sourceImage");
    showImage(convolvedImage, "convolvedImage");
    showImage(dftConvolvedImage, "dftConvolvedImage");
    showImage(deltaImage, "deltaImage");

    final Object o = dftConvolvedImage.getProperty("kernelFT");
    System.out.println("o = " + o);

    System.out.println("Kernel\tConvolve\tDFTConvolve\tPerfGain");
    for (int i = 3; i <= 201; i += 2) {
      KernelJAI k = createBlurrKernel(i);
      double t1 = getRenderTime(ConvolveDescriptor.create(sourceImage, k, hints));
      double t2 = getRenderTime(DFTConvolveDescriptor.create(sourceImage, k, null, hints));
      System.out.println(i + "\t" + t1 + "\t" + t2 + "\t" + t1 / t2);
    }
  }
  private final void initialize() {
    this.setLevel(Level.ALL);
    try {
      LoggerFormat lForm = new LoggerFormat();

      fhand = new FileHandler(ControlRoom.getAppData("vimcsl.%g.log"), 1966080, 5, true);
      fhand.setLevel(Level.ALL);
      fhand.setFormatter(lForm);
      this.addHandler(fhand);

      ConsoleHandler chand = new ConsoleHandler();
      chand.setLevel(Level.ALL);
      chand.setFormatter(lForm);
      this.addHandler(chand);
    } catch (IOException e) {
    }
  }
Ejemplo n.º 18
0
  public static void main(String[] args) throws IOException {
    for (Handler handler : LogManager.getLogManager().getLogger("").getHandlers()) {
      if (handler instanceof ConsoleHandler) {
        ConsoleHandler ch = (ConsoleHandler) handler;
        ch.setFormatter(new ShellFormatter());
        break;
      }
    }

    int commandPort = Integer.parseInt(args[0]);
    int[] ports = new int[args.length - 1];
    for (int i = 0; i < ports.length; i++) {
      ports[i] = Integer.parseInt(args[i + 1]);
    }

    new DeviceReversePortForwarder(commandPort, ports).run();
  }
Ejemplo n.º 19
0
  public void configureLogger(String level, int ttl, boolean debug) {
    if (name == null) return;

    Level logLevel = LecturaCrawlerSuite.convertLogLevel(level);

    logger.setLevel(logLevel);

    // disable passing the logs up to the parent handler
    logger.setUseParentHandlers(false);

    // if debug mode is on, enable console handler
    if (debug) {
      ConsoleHandler consoleHandler = new ConsoleHandler();
      consoleHandler.setLevel(Level.ALL);
      logger.addHandler(consoleHandler);
    }

    logger.addHandler(new MongoLogHandler("log." + name, ttl));
  }
Ejemplo n.º 20
0
  /** @param args the command line arguments */
  public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    // <editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
      for (javax.swing.UIManager.LookAndFeelInfo info :
          javax.swing.UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          javax.swing.UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (ClassNotFoundException ex) {
      java.util.logging.Logger.getLogger(TreeTableTest.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
      java.util.logging.Logger.getLogger(TreeTableTest.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
      java.util.logging.Logger.getLogger(TreeTableTest.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
      java.util.logging.Logger.getLogger(TreeTableTest.class.getName())
          .log(java.util.logging.Level.SEVERE, null, ex);
    }
    // </editor-fold>

    ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(Level.ALL);

    Logger.getLogger("").addHandler(consoleHandler);
    Logger.getLogger(TreeTable.class.getName()).setLevel(Level.ALL);

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            new TreeTableTest().setVisible(true);
          }
        });
  }
Ejemplo n.º 21
0
  /**
   * @param args
   * @throws IOException
   */
  public static void main(String[] args) throws IOException {
    // Activate these lines to see log messages of JmDNS
    boolean log = false;
    if (log) {
      ConsoleHandler handler = new ConsoleHandler();
      handler.setLevel(Level.FINEST);
      for (Enumeration<String> enumerator = LogManager.getLogManager().getLoggerNames();
          enumerator.hasMoreElements(); ) {
        String loggerName = enumerator.nextElement();
        Logger logger = Logger.getLogger(loggerName);
        logger.addHandler(handler);
        logger.setLevel(Level.FINEST);
      }
    }

    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(new ITunesRemotePairing());
    executor.shutdown();
  }
Ejemplo n.º 22
0
 @Override
 public synchronized void flush() {
   try {
     if (jLine) {
       reader.print(ConsoleReader.RESET_LINE + "");
       reader.flush();
       super.flush();
       try {
         reader.drawLine();
       } catch (Throwable ex) {
         reader.getCursorBuffer().clear();
       }
       reader.flush();
     } else {
       super.flush();
     }
   } catch (IOException ex) {
     logger.log(Level.SEVERE, "I/O exception flushing console output", ex);
   }
 }
Ejemplo n.º 23
0
 @Override
 public synchronized void flush() {
   try {
     if (jLine && jTerminal == null) {
       reader.printString(ConsoleReader.RESET_LINE + "");
       reader.flushConsole();
       super.flush();
       try {
         reader.drawLine();
       } catch (Throwable ex) {
         reader.getCursorBuffer().clearBuffer();
       }
       reader.flushConsole();
     } else {
       super.flush();
     }
   } catch (IOException ex) {
     server.getLogger().severe("I/O exception flushing console output");
     ex.printStackTrace();
   }
 }
Ejemplo n.º 24
0
 static {
   logger = Logger.getLogger("javax.xml.bind");
   try {
     if (AccessController.doPrivileged(new GetPropertyAction("jaxb.debug")) != null) {
       // disconnect the logger from a bigger framework (if any)
       // and take the matters into our own hands
       logger.setUseParentHandlers(false);
       logger.setLevel(Level.ALL);
       ConsoleHandler handler = new ConsoleHandler();
       handler.setLevel(Level.ALL);
       logger.addHandler(handler);
     } else {
       // don't change the setting of this logger
       // to honor what other frameworks
       // have done on configurations.
     }
   } catch (Throwable t) {
     // just to be extra safe. in particular System.getProperty may throw
     // SecurityException.
   }
 }
 @Override
 public void publish(LogRecord record) {
   GemFireCacheImpl gemFireCache = GemFireCacheImpl.getInstance();
   if (gemFireCache != null) {
     Logger rootLogger = Logger.getLogger("");
     rootLogger.removeHandler(this);
     Handler gemfireHandler = gemFireCache.getLogger().getHandler();
     rootLogger.addHandler(gemfireHandler);
     gemfireHandler.publish(record);
   } else {
     super.publish(record);
   }
 }
Ejemplo n.º 26
0
  public static void main(String[] args) {
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINE);
    Logger.getLogger("").addHandler(ch);
    Logger.getLogger("").setLevel(Level.FINE);

    // Configure the server.
    ServerBootstrap bootstrap =
        new ServerBootstrap(
            new NioServerSocketChannelFactory(
                Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

    // bootstrap.setOption("child.tcpNoDelay", true);

    // Set up the event pipeline factory.
    bootstrap.setPipelineFactory(new WebSocketServerPipelineFactory());

    // Bind and start to accept incoming connections.
    bootstrap.bind(new InetSocketAddress(9000));

    System.out.println("Web Socket Server started on localhost:9000.");
  }
Ejemplo n.º 27
0
  private void initLogger() {
    ConsoleHandler consoleHandler = null;

    Logger rootLogger = LogManager.getLogManager().getLogger("");
    Handler[] handlers = rootLogger.getHandlers();
    for (Handler handler : handlers) {
      if (handler instanceof ConsoleHandler) {
        consoleHandler = (ConsoleHandler) handler;
        rootLogger.removeHandler(handler);
      }
    }

    logger = Logger.getLogger(contextId);
    logger.setLevel(logLevel);
    if (!logLevel.equals(Level.OFF)) {
      LogFormatter formatter = new LogFormatter();
      if (consoleLog) {
        if (consoleHandler == null) {
          consoleHandler = new ConsoleHandler();
        }
        consoleHandler.setFormatter(formatter);
        consoleHandler.setLevel(logLevel);
        logger.addHandler(consoleHandler);
      }
      String userHomePath = getProperty("user.home", ".");
      File logDir = new File(userHomePath, '.' + contextId + "/log");
      logDir.mkdirs();
      String logFilePattern = new File(logDir, contextId + "-%g.log").getPath();
      try {
        FileHandler fileHandler = new FileHandler(logFilePattern);
        fileHandler.setFormatter(formatter);
        fileHandler.setLevel(logLevel);
        logger.addHandler(fileHandler);
      } catch (IOException e) {
        System.err.println("Error: Failed to create log file: " + logFilePattern);
      }
    }
  }
Ejemplo n.º 28
0
  private static void initLogging() {
    log.setUseParentHandlers(false);

    for (Handler handler : log.getHandlers()) {
      log.removeHandler(handler);
    }

    ConsoleHandler console_handler = new ConsoleHandler();
    console_handler.setFormatter(new ConsoleFormatter());

    if (verbose) {
      console_handler.setLevel(Level.ALL);
    } else {
      console_handler.setLevel(Level.WARNING);
    }

    log.addHandler(console_handler);

    if (log_pattern != null) {
      FileHandler file_handler = null;

      try {
        file_handler = new FileHandler(log_pattern, 1000, 5);
        file_handler.setFormatter(new ConsoleFormatter());
      } catch (IOException ex) {
        log.log(Level.SEVERE, "I/O exception", ex);
        return;
      } catch (SecurityException ex) {
        log.log(Level.SEVERE, "Security exception", ex);
        return;
      }

      file_handler.setLevel(Level.WARNING);
      log.addHandler(file_handler);
    }

    LogManager.getLogManager().addLogger(log);
  }
Ejemplo n.º 29
0
  @Before
  public void setUp() throws Exception {
    cl = ClassLoader.getSystemClassLoader();

    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.ALL);
    Logger.getLogger("").addHandler(handler);
    Logger.getLogger(JsonRpcBasicServer.class.getName()).setLevel(Level.ALL);
    Logger.getLogger(JsonRpcClient.class.getName()).setLevel(Level.ALL);
    jsonRpcServer = new JsonRpcBasicServer(serviceMock, Service.class);
    jsonRpcClient = new JsonRpcClient();

    // create streams
    clientInputStream = new PipedInputStream();
    serverOutputStream = new PipedOutputStream(clientInputStream);
    serverInputStream = new PipedInputStream();
    clientOutputStream = new PipedOutputStream(serverInputStream);

    // start server
    serverThread = new ServerThread(serverInputStream, serverOutputStream, jsonRpcServer);
    serverThread.start();
    serverThread.waitForStart();
  }
Ejemplo n.º 30
0
  /**
   * Initializes the FileHandler. For the name of the log file, a timestamp is used. When the file
   * reaches the size given as the parameter, writing restarts at the beginning of the file.
   *
   * @param maxFilesizeMB the maximum size allowed for the log file (in MB).
   */
  private void initializeHandler(int maxFilesizeMB) {

    if (logFolder.isDirectory()) {

      DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS");
      File logFile = new File(logFolder, formatter.format(new Date()) + ".txt");

      try {
        mFHandler =
            new FileHandler(logFile.getAbsolutePath(), 1024 * 1024 * maxFilesizeMB, 1, true);
        mFHandler.setFormatter(
            new SimpleFormatter() {
              @Override
              public String format(LogRecord record) {
                return super.format(record) + System.getProperty("line.separator");
              }
            });
        mFHandler.setLevel(Level.ALL);
        mLogger.addHandler(mFHandler);

      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    mCHandler = new ConsoleHandler();
    mCHandler.setFormatter(
        new SimpleFormatter() {
          @Override
          public String format(LogRecord record) {
            return super.format(record) + System.getProperty("line.separator");
          }
        });
    mCHandler.setLevel(Level.ALL);
    mLogger.addHandler(mCHandler);
  }