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:org.deviceconnect.android.localoauth.LocalOAuth2Main.java

/**
 * .//  w ww .j av  a2  s  .  co  m
 */
public LocalOAuth2Main(final android.content.Context context, final String dbName) {
    // 
    Logger logger = sLogger;
    if (BuildConfig.DEBUG) {
        AndroidHandler handler = new AndroidHandler(logger.getName());
        handler.setFormatter(new SimpleFormatter());
        handler.setLevel(Level.ALL);
        logger.addHandler(handler);
        logger.setLevel(Level.ALL);
    } else {
        logger.setLevel(Level.OFF);
    }

    mContext = context;

    // DB??
    mDbHelper = new LocalOAuthOpenHelper(context, dbName);
    mDb = mDbHelper.getWritableDatabase();

    // ??
    mUserManager = new SampleUserManager();
    mClientManager = new SQLiteClientManager(mDb);
    mTokenManager = new SQLiteTokenManager(mDb);

    // 
    addUserData(SampleUser.LOCALOAUTH_USER, SampleUser.LOCALOAUTH_PASS);

    register(context);
}

From source file:view.FXApplicationController.java

public void showPopUp(String message) {
    FXPopUp popUp = new FXPopUp();
    popUp.showPopupMessage(message, primaryStage);
    Logger log = Logger.getLogger(this.getClass().getName());
    log.setLevel(Level.ALL);
    log.info(message);//from  ww w.j a  va2 s .  c  om
}

From source file:org.tigase.messenger.phone.pro.service.XMPPService.java

public XMPPService() {
    Logger logger = Logger.getLogger("tigase.jaxmpp");
    Handler handler = new AndroidLoggingHandler();
    handler.setLevel(Level.ALL);/*from ww  w.java  2  s  .c o m*/
    logger.addHandler(handler);
    logger.setLevel(Level.ALL);

}

From source file:de.interactive_instruments.ShapeChange.Target.FeatureCatalogue.FeatureCatalogue.java

private void fopWrite(String xmlName, String xslfofileName, String outfileName, String outputMimetype) {
    Properties outputFormat = OutputPropertiesFactory.getDefaultMethodProperties("xml");
    outputFormat.setProperty("indent", "yes");
    outputFormat.setProperty("{http://xml.apache.org/xalan}indent-amount", "2");
    outputFormat.setProperty("encoding", encoding);

    // redirect FOP-logging to our system, Level 'Warning' by default
    Logger fl = Logger.getLogger("org.apache.fop");
    fl.setLevel(Level.WARNING);
    FopMsgHandler fmh = new FopMsgHandler(result, this);
    fl.addHandler(fmh);/*from   w  w  w  . j a  va 2s. c  o  m*/

    try {
        // configure fopFactory as desired
        FopFactory fopFactory = FopFactory.newInstance();

        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        // configure foUserAgent as desired

        boolean skip = false;

        // Setup directories
        File outDir = new File(outputDirectory);

        // Setup input and output files
        File xmlFile = new File(outDir, xmlName);
        File xsltFile = new File(xsltPath, xslfofileName);
        File outFile = new File(outDir, outfileName);

        if (!xmlFile.canRead()) {
            result.addError(null, 301, xmlFile.getName(), outfileName);
            skip = true;
        }
        if (!xsltFile.canRead()) {
            result.addError(null, 301, xsltFile.getName(), outfileName);
            skip = true;
        }

        if (skip == false) {
            // Setup output
            OutputStream out = null;
            try {
                out = new java.io.FileOutputStream(outFile);
                out = new java.io.BufferedOutputStream(out);
            } catch (Exception e) {
                result.addError(null, 304, outFile.getName(), e.getMessage());
                skip = true;
            }
            if (skip == false) {
                try {
                    // Construct fop with desired output format
                    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

                    // Setup XSLT
                    if (xslTransformerFactory != null) {
                        // use TransformerFactory specified in configuration
                        System.setProperty("javax.xml.transform.TransformerFactory", xslTransformerFactory);
                    } else {
                        // use TransformerFactory determined by system
                    }
                    TransformerFactory factory = TransformerFactory.newInstance();
                    Transformer transformer = factory.newTransformer(new StreamSource(xsltFile));

                    FopErrorListener el = new FopErrorListener(xmlFile.getName(), result, this);
                    transformer.setErrorListener(el);

                    // Set the value of a <param> in the stylesheet
                    transformer.setParameter("versionParam", "2.0");

                    // Setup input for XSLT transformation
                    Source src = new StreamSource(xmlFile);

                    // Resulting SAX events (the generated FO) must be piped
                    // through to FOP
                    Result res = new SAXResult(fop.getDefaultHandler());

                    // Start XSLT transformation and FOP processing
                    transformer.transform(src, res);

                } catch (Exception e) {
                    result.addError(null, 304, outfileName, e.getMessage());
                    skip = true;
                } finally {
                    out.close();
                    result.addResult(getTargetID(), outputDirectory, outfileName, null);
                    if (deleteXmlFile)
                        xmlFile.delete();
                }
            }
        }

    } catch (Exception e) {
        String m = e.getMessage();
        if (m != null) {
            result.addError(m);
        }
        e.printStackTrace(System.err);
    }
}