Example usage for java.util.logging Logger getName

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

Introduction

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

Prototype

public String getName() 

Source Link

Document

Get the name for this logger.

Usage

From source file:org.deviceconnect.android.localoauth.LocalOAuth2Main.java

/**
 * .//from  w w w  . ja v a  2s.c om
 */
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:pl.otros.logview.importer.UtilLoggingXmlLogImporter.java

/**
 * Given a Document, converts the XML into a Vector of LoggingEvents.
 *
 * @param document//from  ww w  .j  a va  2  s.c o  m
 *          XML document
 * @return Vector of LoggingEvents
 */
private void decodeEvents(final Document document, LogDataCollector collector, ParsingContext parsingContext) {

    NodeList eventList = document.getElementsByTagName("record");

    for (int eventIndex = 0; eventIndex < eventList.getLength(); eventIndex++) {
        Node eventNode = eventList.item(eventIndex);

        Logger logger = null;
        long timeStamp = 0L;
        Level level = null;
        String threadName = null;
        Object message = null;
        String className = null;
        String methodName = null;
        String exceptionStackTrace = null;

        // format of date: 2003-05-04T11:04:52
        // ignore date or set as a property? using millis in constructor instead
        NodeList list = eventNode.getChildNodes();
        int listLength = list.getLength();

        if (listLength == 0) {
            continue;
        }

        for (int y = 0; y < listLength; y++) {
            Node logEventNode = list.item(y);
            String tagName = logEventNode.getNodeName();

            if (tagName.equalsIgnoreCase("logger")) {
                logger = Logger.getLogger(getCData(list.item(y)));
            } else if (tagName.equalsIgnoreCase("millis")) {
                timeStamp = Long.parseLong(getCData(list.item(y)));
            } else

            if (tagName.equalsIgnoreCase("level")) {
                level = Level.parse(getCData(list.item(y)));
            } else

            if (tagName.equalsIgnoreCase("thread")) {
                threadName = getCData(list.item(y));
            } else

            if (tagName.equalsIgnoreCase("message")) {
                message = getCData(list.item(y));
            } else

            if (tagName.equalsIgnoreCase("class")) {
                className = getCData(list.item(y));
            } else

            if (tagName.equalsIgnoreCase("method")) {
                methodName = getCData(list.item(y));
            } else if (tagName.equalsIgnoreCase("exception")) {
                exceptionStackTrace = getExceptionStackTrace(list.item(y));

            }

        }
        if (message != null && exceptionStackTrace != null) {
            message = message + "\n" + exceptionStackTrace;
        } else if (exceptionStackTrace != null) {
            message = exceptionStackTrace;
        }
        LogData logData = new LogData();
        logData.setLevel(level);
        logData.setClazz(className);
        logData.setId(parsingContext.getGeneratedIdAndIncrease());
        logData.setDate(new Date(timeStamp));
        logData.setLoggerName(logger.getName());
        logData.setMessage(StringUtils.defaultString(message != null ? message.toString() : ""));
        logData.setThread(threadName);
        logData.setMethod(methodName);
        logData.setLogSource(parsingContext.getLogSource());
        collector.add(logData);

    }
}