Example usage for java.util.logging Logger setLevel

List of usage examples for java.util.logging Logger setLevel

Introduction

In this page you can find the example usage for java.util.logging Logger setLevel.

Prototype

public void setLevel(Level newLevel) throws SecurityException 

Source Link

Document

Set the log level specifying which message levels will be logged by this logger.

Usage

From source file:com.canoo.dolphin.todo.client.ToDoClient.java

public static void main(String[] args) {
    Logger OD_LOGGER = Logger.getLogger("org.opendolphin");
    OD_LOGGER.setLevel(Level.SEVERE);

    Application.launch(args);//www .  j  av  a 2s  .c  om
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    LogManager lm = LogManager.getLogManager();
    Logger logger;
    FileHandler fh = new FileHandler("log_test.txt");

    logger = Logger.getLogger("LoggingExample1");

    lm.addLogger(logger);/*  w w  w . ja  va 2s  . c  o m*/
    logger.setLevel(Level.INFO);
    fh.setFormatter(new XMLFormatter());

    logger.addHandler(fh);
    //logger.setUseParentHandlers(false);
    logger.log(Level.INFO, "test 1");
    logger.log(Level.INFO, "test 2");
    logger.log(Level.INFO, "test 3");
    fh.close();
}

From source file:LoggingExample1.java

public static void main(String args[]) {
    try {//from ww w .j  ava 2 s  .co  m
        LogManager lm = LogManager.getLogManager();
        Logger logger;
        FileHandler fh = new FileHandler("log_test.txt");

        logger = Logger.getLogger("LoggingExample1");

        lm.addLogger(logger);
        logger.setLevel(Level.INFO);
        fh.setFormatter(new XMLFormatter());

        logger.addHandler(fh);
        //logger.setUseParentHandlers(false);
        logger.log(Level.INFO, "test 1");
        logger.log(Level.INFO, "test 2");
        logger.log(Level.INFO, "test 3");
        fh.close();
    } catch (Exception e) {
        System.out.println("Exception thrown: " + e);
        e.printStackTrace();
    }
}

From source file:de.fosd.jdime.JDimeWrapper.java

public static void main(String[] args) throws IOException, InterruptedException {
    // setup logging
    Logger root = Logger.getLogger(JDimeWrapper.class.getPackage().getName());
    root.setLevel(Level.WARNING);

    for (Handler handler : root.getHandlers()) {
        handler.setLevel(Level.WARNING);
    }//w  w w  .j a  v  a  2  s  .  c  o  m

    // setup JDime using the MergeContext
    MergeContext context = new MergeContext();
    context.setPretend(true);
    context.setQuiet(false);

    // prepare the list of input files
    ArtifactList<FileArtifact> inputArtifacts = new ArtifactList<>();

    for (String filename : args) {
        try {
            File file = new File(filename);

            // the revision name, this will be used as condition for ifdefs
            // as an example, I'll just use the filenames
            Revision rev = new Revision(FilenameUtils.getBaseName(file.getPath()));
            FileArtifact newArtifact = new FileArtifact(rev, file);

            inputArtifacts.add(newArtifact);
        } catch (FileNotFoundException e) {
            System.err.println("Input file not found: " + filename);
        }
    }

    context.setInputFiles(inputArtifacts);

    // setup strategies
    MergeStrategy<FileArtifact> structured = new StructuredStrategy();
    MergeStrategy<FileArtifact> conditional = new NWayStrategy();

    // run the merge first with structured strategy to see whether there are conflicts
    context.setMergeStrategy(structured);
    context.collectStatistics(true);
    Operation<FileArtifact> merge = new MergeOperation<>(context.getInputFiles(), context.getOutputFile(), null,
            null, context.isConditionalMerge());
    merge.apply(context);

    // if there are no conflicts, run the conditional strategy
    if (context.getStatistics().hasConflicts()) {
        context = new MergeContext(context);
        context.collectStatistics(false);
        context.setMergeStrategy(conditional);
        // use regular merging outside of methods
        context.setConditionalOutsideMethods(false);
        // we have to recreate the operation because now we will do a conditional merge
        merge = new MergeOperation<>(context.getInputFiles(), context.getOutputFile(), null, null,
                context.isConditionalMerge());
        merge.apply(context);
    }
}

From source file:MyHtmlFormatter.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger("com.mycompany");
    FileHandler fh = new FileHandler("mylog.html");
    fh.setFormatter(new MyHtmlFormatter());
    logger.addHandler(fh);/*ww w  . ja v  a  2s  . com*/

    logger.setLevel(Level.ALL);
    logger.severe("my severe message");
    logger.info("my info message");
    logger.entering("Main class", "myMethod", new Object[] { "para1", "para2" });
}

From source file:net.zdechov.sharpmz.jmzemu.JMzEmu.java

/**
 * Main method launching the application.
 *
 * @param args arguments/*  ww w.  j  a va 2  s .c o  m*/
 */
public static void main(String[] args) {

    try {
        preferences = Preferences.userNodeForPackage(JMzEmu.class);
    } catch (SecurityException ex) {
        preferences = null;
    }
    try {
        bundle = LanguageUtils.getResourceBundleByClass(JMzEmu.class);
        // Parameters processing
        Options opt = new Options();
        opt.addOption("h", "help", false, bundle.getString("cl_option_help"));
        opt.addOption("v", false, bundle.getString("cl_option_verbose"));
        opt.addOption("dev", false, bundle.getString("cl_option_dev"));
        BasicParser parser = new BasicParser();
        CommandLine cl = parser.parse(opt, args);
        if (cl.hasOption('h')) {
            HelpFormatter f = new HelpFormatter();
            f.printHelp(bundle.getString("cl_syntax"), opt);
        } else {
            verboseMode = cl.hasOption("v");
            devMode = cl.hasOption("dev");
            Logger logger = Logger.getLogger("");
            try {
                logger.setLevel(Level.ALL);
                logger.addHandler(new XBHead.XBLogHandler(verboseMode));
            } catch (java.security.AccessControlException ex) {
                // Ignore it in java webstart
            }

            XBBaseApplication app = new XBBaseApplication();
            app.setAppPreferences(new PreferencesWrapper(preferences));
            app.setAppBundle(bundle, LanguageUtils.getResourceBaseNameBundleByClass(JMzEmu.class));

            XBApplicationModuleRepository moduleRepository = app.getModuleRepository();
            moduleRepository.addClassPathModules();
            moduleRepository.addModulesFromManifest(JMzEmu.class);
            moduleRepository.loadModulesFromPath(new File("plugins").toURI());
            moduleRepository.initModules();
            app.init();

            GuiFrameModuleApi frameModule = moduleRepository.getModuleByInterface(GuiFrameModuleApi.class);
            GuiEditorModuleApi editorModule = moduleRepository.getModuleByInterface(GuiEditorModuleApi.class);
            GuiMenuModuleApi menuModule = moduleRepository.getModuleByInterface(GuiMenuModuleApi.class);
            GuiAboutModuleApi aboutModule = moduleRepository.getModuleByInterface(GuiAboutModuleApi.class);
            GuiFileModuleApi fileModule = moduleRepository.getModuleByInterface(GuiFileModuleApi.class);
            GuiOptionsModuleApi optionsModule = moduleRepository
                    .getModuleByInterface(GuiOptionsModuleApi.class);
            GuiUpdateModuleApi updateModule = moduleRepository.getModuleByInterface(GuiUpdateModuleApi.class);
            frameModule.createMainMenu();

            //                try {
            //                    updateModule.setUpdateUrl(new URL(bundle.getString("update_url")));
            //                    updateModule.setUpdateDownloadUrl(new URL(bundle.getString("update_download_url")));
            //                } catch (MalformedURLException ex) {
            //                    Logger.getLogger(JMzEmu.class.getName()).log(Level.SEVERE, null, ex);
            //                }
            updateModule.registerDefaultMenuItem();
            aboutModule.registerDefaultMenuItem();
            AboutDialogSidePanel sidePanel = new AboutDialogSidePanel();
            aboutModule.setAboutDialogSideComponent(sidePanel);

            frameModule.registerExitAction();
            frameModule.registerBarsVisibilityActions();

            // Register clipboard editing actions
            fileModule.registerMenuFileHandlingActions();
            fileModule.registerToolBarFileHandlingActions();
            fileModule.registerLastOpenedMenuActions();
            fileModule.registerCloseListener();

            //                undoModule.registerMainMenu();
            //                undoModule.registerMainToolBar();
            //                undoModule.registerUndoManagerInMainMenu();
            // Register clipboard editing actions
            menuModule.getClipboardActions();
            //                menuModule.registerMenuClipboardActions();
            //                menuModule.registerToolBarClipboardActions();
            optionsModule.registerMenuAction();

            //                HexPanel hexPanel = (HexPanel) deltaHexModule.getEditorProvider();
            //                editorModule.registerEditor("hex", hexPanel);
            //                editorModule.registerUndoHandler();
            //                undoModule.setUndoHandler(hexPanel.getHexUndoHandler());
            //                deltaHexModule.registerStatusBar();
            //                deltaHexModule.registerOptionsPanels();
            //                deltaHexModule.getTextStatusPanel();
            updateModule.registerOptionsPanels();

            //                deltaHexModule.loadFromPreferences(preferences);
            ApplicationFrameHandler frameHandler = frameModule.getFrameHandler();
            GraphicsModule graphicsModule = new GraphicsModule();
            frameHandler.setMainPanel(graphicsModule.getGraphicsComponent());
            frameHandler.setDefaultSize(new Dimension(600, 400));
            frameHandler.show();
            updateModule.checkOnStart(frameHandler.getFrame());

            List fileArgs = cl.getArgList();
            if (fileArgs.size() > 0) {
                fileModule.loadFromFile((String) fileArgs.get(0));
            }
        }
    } catch (ParseException | RuntimeException ex) {
        Logger.getLogger(JMzEmu.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.left8.evs.evs.EvS.java

/**
 * Main method that provides a simple console input interface for the user,
 * if she wishes to execute the tool as a .jar executable.
 * @param args A list of arguments./*from  ww  w . ja va  2 s .  c o m*/
 * @throws org.apache.commons.cli.ParseException ParseExcetion
 */
public static void main(String[] args) throws ParseException {

    Config config = null;
    try {
        config = new Config();
    } catch (IOException ex) {
        Utilities.printMessageln("Configuration file 'config.properties' " + "not in classpath!");
        Logger.getLogger(EvS.class.getName()).log(Level.SEVERE, null, ex);
        System.exit(1);
    }

    if (args.length != 0) { //If the user supplied arguments
        Console console = new Console(args, config); //Read the console

        showMongoLogging = console.showMongoLogging();
        showInlineInfo = console.showInlineInfo();
        hasExtCommands = console.hasExternalCommands();
        choice = console.getChoiceValue();
    }

    if (!showMongoLogging) {
        //Stop reporting logging information
        Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
        mongoLogger.setLevel(Level.SEVERE);
    }

    System.out.println("\n----EvS----");

    if (!hasExtCommands) {
        System.out.println("Select one of the following options");
        System.out.println("1. Run Offline Peak Finding experiments.");
        System.out.println("2. Run EDCoW experiments.");
        System.out.println("3. Run each of the above methods without " + "the sentiment annotations.");
        System.out.println("Any other key to exit.");
        System.out.println("");
        System.out.print("Your choice: ");

        Scanner keyboard = new Scanner(System.in);
        choice = keyboard.nextInt();
    }

    switch (choice) {
    case 1: { //Offline Peak Finding
        int window = 10;
        double alpha = 0.85;
        int taph = 1;
        int pi = 5;
        Dataset ds = new Dataset(config);
        PeakFindingCorpus corpus = new PeakFindingCorpus(config, ds.getTweetList(), ds.getSWH());
        corpus.createCorpus(window);

        List<BinPair<String, Integer>> bins = BinsCreator.createBins(corpus, config, window);
        PeakFindingSentimentCorpus sCorpus = new PeakFindingSentimentCorpus(corpus);

        SentimentPeakFindingExperimenter exper = new SentimentPeakFindingExperimenter(sCorpus, bins, alpha,
                taph, pi, window, config);

        //Experiment with Taph
        List<String> lines = exper.experimentUsingTaph(1, 10, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingTaph(1, 10, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingTaph(1, 10, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        //Experiment with Alpha
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        break;
    }
    case 2: { //EDCoW
        Dataset ds = new Dataset(config);
        SentimentEDCoWCorpus corpus = new SentimentEDCoWCorpus(config, ds.getTweetList(), ds.getSWH(), 10);

        corpus.getEDCoWCorpus().createCorpus();
        corpus.getEDCoWCorpus().setDocTermFreqIdList();
        int delta = 5, delta2 = 11, gamma = 6;
        double minTermSupport = 0.001, maxTermSupport = 0.01;

        SentimentEDCoWExperimenter exper = new SentimentEDCoWExperimenter(corpus, delta, delta2, gamma,
                minTermSupport, maxTermSupport, choice, choice, config);

        //Experiment with delta
        List<String> lines = exper.experimentUsingDelta(1, 20, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingDelta(1, 20, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingDelta(1, 20, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        //Experiment with gamma
        lines = exper.experimentUsingGamma(6, 10, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingGamma(6, 10, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingGamma(6, 10, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        break;
    }
    case 3: {
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 0);
        break;
    }
    case 4: { //Directly run OPF
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 1);
        break;
    }
    case 5: { //Directly run EDCoW
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 2);
        break;
    }
    default: {
        System.out.println("Exiting now...");
        System.exit(0);
    }
    }
}

From source file:org.exbin.deltahex.editor.DeltaHexEditor.java

/**
 * Main method launching the application.
 *
 * @param args arguments//from  ww w  .  j  a v  a 2  s  .c  o m
 */
public static void main(String[] args) {
    try {
        preferences = Preferences.userNodeForPackage(DeltaHexEditor.class);
    } catch (SecurityException ex) {
        preferences = null;
    }
    try {
        bundle = LanguageUtils.getResourceBundleByClass(DeltaHexEditor.class);
        // Parameters processing
        Options opt = new Options();
        opt.addOption("h", "help", false, bundle.getString("cl_option_help"));
        opt.addOption("v", false, bundle.getString("cl_option_verbose"));
        opt.addOption("dev", false, bundle.getString("cl_option_dev"));
        BasicParser parser = new BasicParser();
        CommandLine cl = parser.parse(opt, args);
        if (cl.hasOption('h')) {
            HelpFormatter f = new HelpFormatter();
            f.printHelp(bundle.getString("cl_syntax"), opt);
        } else {
            verboseMode = cl.hasOption("v");
            devMode = cl.hasOption("dev");
            Logger logger = Logger.getLogger("");
            try {
                logger.setLevel(Level.ALL);
                logger.addHandler(new XBHead.XBLogHandler(verboseMode));
            } catch (java.security.AccessControlException ex) {
                // Ignore it in java webstart
            }

            XBBaseApplication app = new XBBaseApplication();
            app.setAppPreferences(preferences);
            app.setAppBundle(bundle, LanguageUtils.getResourceBaseNameBundleByClass(DeltaHexEditor.class));

            XBApplicationModuleRepository moduleRepository = app.getModuleRepository();
            moduleRepository.addClassPathModules();
            moduleRepository.addModulesFromManifest(DeltaHexEditor.class);
            moduleRepository.loadModulesFromPath(new File("plugins").toURI());
            moduleRepository.initModules();
            app.init();

            GuiFrameModuleApi frameModule = moduleRepository.getModuleByInterface(GuiFrameModuleApi.class);
            GuiEditorModuleApi editorModule = moduleRepository.getModuleByInterface(GuiEditorModuleApi.class);
            GuiMenuModuleApi menuModule = moduleRepository.getModuleByInterface(GuiMenuModuleApi.class);
            GuiAboutModuleApi aboutModule = moduleRepository.getModuleByInterface(GuiAboutModuleApi.class);
            GuiUndoModuleApi undoModule = moduleRepository.getModuleByInterface(GuiUndoModuleApi.class);
            GuiFileModuleApi fileModule = moduleRepository.getModuleByInterface(GuiFileModuleApi.class);
            GuiOptionsModuleApi optionsModule = moduleRepository
                    .getModuleByInterface(GuiOptionsModuleApi.class);
            GuiDockingModuleApi dockingModule = moduleRepository
                    .getModuleByInterface(GuiDockingModuleApi.class);
            GuiUpdateModuleApi updateModule = moduleRepository.getModuleByInterface(GuiUpdateModuleApi.class);

            DeltaHexModule deltaHexModule = moduleRepository.getModuleByInterface(DeltaHexModule.class);

            frameModule.createMainMenu();
            try {
                updateModule.setUpdateUrl(new URL(bundle.getString("update_url")));
                updateModule.setUpdateDownloadUrl(new URL(bundle.getString("update_download_url")));
            } catch (MalformedURLException ex) {
                Logger.getLogger(DeltaHexEditor.class.getName()).log(Level.SEVERE, null, ex);
            }
            updateModule.registerDefaultMenuItem();
            aboutModule.registerDefaultMenuItem();

            frameModule.registerExitAction();
            frameModule.registerBarsVisibilityActions();
            //                Component dockingPanel = dockingModule.getDockingPanel();

            // Register clipboard editing actions
            fileModule.registerMenuFileHandlingActions();
            fileModule.registerToolBarFileHandlingActions();
            fileModule.registerLastOpenedMenuActions();
            fileModule.registerCloseListener();

            undoModule.registerMainMenu();
            undoModule.registerMainToolBar();
            undoModule.registerUndoManagerInMainMenu();

            // Register clipboard editing actions
            menuModule.registerMenuClipboardActions();
            menuModule.registerToolBarClipboardActions();

            optionsModule.registerMenuAction();

            //                HexEditorProvider editorProvider = deltaHexModule.getMultiEditorProvider();
            HexEditorProvider editorProvider = deltaHexModule.getEditorProvider();
            deltaHexModule.registerEditFindMenuActions();
            deltaHexModule.registerEditFindToolBarActions();
            deltaHexModule.registerViewNonprintablesMenuActions();
            deltaHexModule.registerToolsOptionsMenuActions();
            deltaHexModule.registerClipboardCodeActions();
            deltaHexModule.registerOptionsMenuPanels();
            deltaHexModule.registerGoToLine();
            deltaHexModule.registerPropertiesMenu();
            deltaHexModule.registerPrintMenu();
            deltaHexModule.registerViewModeMenu();
            deltaHexModule.registerCodeTypeMenu();
            deltaHexModule.registerPositionCodeTypeMenu();
            deltaHexModule.registerHexCharactersCaseHandlerMenu();
            deltaHexModule.registerWordWrapping();

            ApplicationFrameHandler frameHandler = frameModule.getFrameHandler();
            editorModule.registerEditor("hex", editorProvider);
            // editorModule.registerMultiEditor("hex", (MultiEditorProvider) editorProvider);
            editorModule.registerUndoHandler();
            undoModule.setUndoHandler(editorProvider.getHexUndoHandler());

            deltaHexModule.registerStatusBar();
            deltaHexModule.registerOptionsPanels();
            deltaHexModule.getTextStatusPanel();
            updateModule.registerOptionsPanels();

            deltaHexModule.loadFromPreferences(preferences);

            //                frameHandler.setMainPanel(dockingPanel);
            // Single editor only
            frameHandler.setMainPanel(editorModule.getEditorPanel());
            frameHandler.setDefaultSize(new Dimension(600, 400));
            frameHandler.show();
            updateModule.checkOnStart(frameHandler.getFrame());

            List fileArgs = cl.getArgList();
            if (fileArgs.size() > 0) {
                fileModule.loadFromFile((String) fileArgs.get(0));
            }
        }
    } catch (ParseException | RuntimeException ex) {
        Logger.getLogger(DeltaHexEditor.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:HTMLFormatter.java

public static void main(String args[]) throws Exception {
    LogManager lm = LogManager.getLogManager();
    Logger parentLogger, childLogger;
    FileHandler xml_handler = new FileHandler("log_output.xml");
    FileHandler html_handler = new FileHandler("log_output.html");
    parentLogger = Logger.getLogger("ParentLogger");
    childLogger = Logger.getLogger("ParentLogger.ChildLogger");

    lm.addLogger(parentLogger);/* w  ww.  j  a v  a 2s .  co m*/

    lm.addLogger(childLogger);

    parentLogger.setLevel(Level.WARNING);
    childLogger.setLevel(Level.ALL);
    xml_handler.setFormatter(new XMLFormatter());
    html_handler.setFormatter(new HTMLFormatter());

    parentLogger.addHandler(xml_handler);
    childLogger.addHandler(html_handler);

    childLogger.log(Level.FINE, "This is a fine log message");
    childLogger.log(Level.SEVERE, "This is a severe log message");
    xml_handler.close();
    html_handler.close();
}

From source file:net.nharyes.drivecopy.Main.java

public static void main(String[] args) {

    // set logger handler
    Logger logger = Logger.getLogger(Main.class.getPackage().getName());
    logger.setUseParentHandlers(false);/*from www .j  a  v  a 2s.  c  o m*/
    logger.addHandler(new SystemOutHandler());
    logger.setLevel(Level.FINE);

    new Main(args);
}