当前位置: 首页>>代码示例>>Java>>正文


Java Logger.log方法代码示例

本文整理汇总了Java中java.util.logging.Logger.log方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.log方法的具体用法?Java Logger.log怎么用?Java Logger.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Logger的用法示例。


在下文中一共展示了Logger.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleUserFollowed

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void handleUserFollowed(LiveEvent event, JsonObject payload) {
	try {
		if (Files.notExists(Paths.get("payloads\\"))) {
			new File("payloads\\").mkdir();
		}

		Logger logger = Logger.getLogger("payload-userFollowed");
		FileHandler fh = new FileHandler("payloads\\" + logger.getName() + ".json");
		SimpleFormatter formatter = new SimpleFormatter();
		fh.setFormatter(formatter);

		logger.addHandler(fh);

		logger.log(Level.INFO, payload.toString());
	} catch (SecurityException | IOException e) {}
}
 
开发者ID:StreamerSpectrum,项目名称:BeamTeamDiscordBot,代码行数:17,代码来源:ConstellationManager.java

示例2: conectarBase

import java.util.logging.Logger; //导入方法依赖的package包/类
public static Connection conectarBase(){
	 Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        try {Class.forName("org.postgresql.Driver");}
        catch (ClassNotFoundException e) {e.printStackTrace();}
        String url = "";
        String user = "bpm";
        String password = "cybiraconsulting2";

        try {con = DriverManager.getConnection("jdbc:postgresql://pg02.stp.gov.py/base?useUnicode=true&characterEncoding=UTF-8&user=bpm&password=cybiraconsulting2");}
        catch (SQLException ex) {
            Logger lgr = Logger.getLogger(SqlHelper.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
        } 
        return con;
}
 
开发者ID:stppy,项目名称:tcp,代码行数:18,代码来源:ConnectionConfiguration.java

示例3: conectar

import java.util.logging.Logger; //导入方法依赖的package包/类
public static Connection conectar(){
	 Connection con = null; 
        Statement st = null;
        ResultSet rs = null;
        try {Class.forName("org.postgresql.Driver");}
        catch (ClassNotFoundException e) {e.printStackTrace();}
        String url = "";
        String user = "postgres";
        String password = "postgres";

        try {con = DriverManager.getConnection("jdbc:postgresql://pg01.stp.gov.py/tablero2015v3?useUnicode=true&characterEncoding=UTF-8&user=postgres&password=postgres");}
        catch (SQLException ex) {
            Logger lgr = Logger.getLogger(SqlHelper.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
        } 
        return con;
}
 
开发者ID:stppy,项目名称:tcp,代码行数:18,代码来源:ConnectionConfiguration.java

示例4: deactivateUser

import java.util.logging.Logger; //导入方法依赖的package包/类
public boolean deactivateUser(int id) throws SQLException {
	Logger logger = Logger.getLogger(DataAccess.class.getName());
	logger.log(Level.INFO, "deactivateUser starting...");
	PreparedStatement stm = c.prepareStatement(SQLStatements.selectUserById);
	stm.setInt(1, id);
	ResultSet rs = stm.executeQuery();
	if (rs.next()) {
		logger.log(Level.INFO, "deactivateUser User found:" + id);
		rs.close();
		stm.close();
		PreparedStatement stm2 = c.prepareStatement(SQLStatements.setUserDeactiveById);
		stm2.setInt(1, id);
		stm2.executeUpdate();
		stm2.close();
		return true;
	}
	logger.log(Level.WARNING, "deactivateUser User NOT found");
	rs.close();
	stm.close();

	return false;
}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:23,代码来源:DataAccess.java

示例5: testLoggingMessageWithBundle

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testLoggingMessageWithBundle() throws Exception {
    FileObject dir  = TimesCollectorPeerTest.makeScratchDir(this);
    
    Logger LOG = Logger.getLogger("TIMER.instance.of.my.object");
    LogRecord rec = new LogRecord(Level.FINE, "LOG_Project"); // NOI18N
    rec.setParameters(new Object[] { dir, dir });
    rec.setResourceBundle(ResourceBundle.getBundle(HandlerTest.class.getName()));
    LOG.log(rec);

    Collection<Object> files = TimesCollectorPeer.getDefault().getFiles();
    assertEquals("One object " + files, 1, files.size());
    
    Description descr = TimesCollectorPeer.getDefault().getDescription(files.iterator().next(), "LOG_Project");
    assertNotNull(descr);
    
    if (descr.getMessage().indexOf("My Project") == -1) {
        fail("Localized msg should contain 'My Project': " + descr.getMessage());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:HandlerTest.java

示例6: testSendLogWithException

import java.util.logging.Logger; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #7964
public void testSendLogWithException() throws Exception {
    Logger uiLogger = Logger.getLogger(Installer.UI_LOGGER_NAME);
    LogRecord log1 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
    LogRecord log2 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
    LogRecord log3 = new LogRecord(Level.SEVERE, "NO EXCEPTION LOG");
    LogRecord log4 = new LogRecord(Level.INFO, "INFO");
    Throwable t1 = new NullPointerException("TESTING THROWABLE");
    Throwable t2 = new UnknownError("TESTING ERROR");
    log1.setThrown(t1);
    log2.setThrown(t2);
    log4.setThrown(t2);
    Installer installer = Installer.findObject(Installer.class, true);
    assertNotNull(installer);
    installer.restored();
    uiLogger.log(log1);
    uiLogger.log(log2);
    uiLogger.log(log3);
    UIHandler.waitFlushed();
    if (Installer.getThrown() == null) {
        fail("Exception should be found in the log");
    }
    
    doEncodingTest("UTF-8", "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></meta>");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:InstallerReadPageTest.java

示例7: conectarSpr

import java.util.logging.Logger; //导入方法依赖的package包/类
public static Connection conectarSpr(){
	 Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        //try {Class.forName("com.mysql.jdbc.Driver");}
        try {Class.forName("org.postgresql.Driver");}
        catch (ClassNotFoundException e) {e.printStackTrace();}
        String url = "";
        //String user = "root";
        String user = "postgres";
        String password = "postgres";

        //try {con = DriverManager.getConnection("jdbc:mysql://mysql01.stp.gov.py/spr?useUnicode=true&characterEncoding=UTF-8", "root", "postgres");}
        try {con = DriverManager.getConnection("jdbc:postgresql://pg01.stp.gov.py/spr?useUnicode=true&characterEncoding=UTF-8", "postgres", "postgres");}
        catch (SQLException ex) {
            Logger lgr = Logger.getLogger(SqlHelper.class.getName());
            lgr.log(Level.SEVERE, ex.getMessage(), ex);
        } 
        return con;
}
 
开发者ID:stppy,项目名称:tcp,代码行数:21,代码来源:ConnectionConfiguration.java

示例8: run

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void run() {
    try {
        long rest, previous;
        int msgCount = 0;
        previous = time;
        Logger logger =  Logger.getLogger("remaining");
        while (goOn && (rest = start - System.currentTimeMillis() + time) > 0) {
            if (previous == time || previous - rest >= STEP) {
                logger.log(Level.INFO, "{0}ms remaining...", String.valueOf(rest));
                msgCount++;
                previous = rest == time ? rest -1 : rest;
                System.gc();
            }
            if (goOn == false) break;
            pause(Math.min(rest, 100));
        }
        System.err.println(this + ": " + msgCount + " messages.");
        System.err.flush();
        System.out.println(System.currentTimeMillis() - start
                + " ms elapsed ("+time+ " requested)");
        goOn = false;
    } catch(InterruptedException | RuntimeException x) {
        fail(x);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TestConfigurationLock.java

示例9: dumpThread

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void dumpThread(ThreadInfo thread, Logger log, Level level)
{
    if (thread == null) return;
    if ( thread.getThreadState() != State.WAITING )
    {
        log.log( level, "------------------------------" );
        //
        log.log( level, "Current Thread: " + thread.getThreadName() );
        log.log( level, "\tPID: " + thread.getThreadId()
                + " | Suspended: " + thread.isSuspended()
                + " | Native: " + thread.isInNative()
                + " | State: " + thread.getThreadState() 
                + " | Blocked Time: " + thread.getBlockedTime()     // Cauldron add info about blocked time
                + " | Blocked Count: " + thread.getBlockedCount()); // Cauldron add info about blocked count
        
        if ( thread.getLockedMonitors().length != 0 )
        {
            log.log( level, "\tThread is waiting on monitor(s):" );
            for ( MonitorInfo monitor : thread.getLockedMonitors() )
            {
                log.log( level, "\t\tLocked on:" + monitor.getLockedStackFrame() );
            }
        }
        if ( thread.getLockOwnerId() != -1 ) log.log( level, "\tLock Owner Id: " + thread.getLockOwnerId()); // Cauldron + add info about lock owner thread id
        log.log( level, "\tStack:" );
        //
        StackTraceElement[] stack = thread.getStackTrace();
        for ( int line = 0; line < stack.length; line++ )
        {
            log.log( level, "\t\t" + stack[line].toString() );
        }
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:34,代码来源:WatchdogThread.java

示例10: isValidReportFile

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 */
private boolean isValidReportFile(File reportFile) {
    if (!reportFile.canRead()) {
        return false;
    }
    
    long lastModified = reportFile.lastModified();
    long timeDelta = lastModified - timeOfSessionStart;
    
    final Logger logger = Logger.getLogger("org.netbeans.modules.junit.outputreader.timestamps");//NOI18N
    final Level logLevel = FINER;
    if (logger.isLoggable(logLevel)) {
        logger.log(logLevel, "Report file: " + reportFile.getPath());//NOI18N
        
        final GregorianCalendar timeStamp = new GregorianCalendar();
        
        timeStamp.setTimeInMillis(timeOfSessionStart);
        logger.log(logLevel, "Session start:    " + String.format("%1$tT.%2$03d", timeStamp, timeStamp.get(GregorianCalendar.MILLISECOND)));//NOI18N
        
        timeStamp.setTimeInMillis(lastModified);
        logger.log(logLevel, "Report timestamp: " + String.format("%1$tT.%2$03d", timeStamp, timeStamp.get(GregorianCalendar.MILLISECOND)));//NOI18N
    }
    
    if (timeDelta >= 0) {
        return true;
    }
    
    return -timeDelta <= timeOfSessionStart % 1000;
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:JUnitOutputReader.java

示例11: testConcurrentScanDeadlock

import java.util.logging.Logger; //导入方法依赖的package包/类
public void testConcurrentScanDeadlock() throws Exception {
    final Logger LOG = Logger.getLogger("org.netbeans.modules.apisupport.project.universe.ModuleList");
    Logger observer = Logger.getLogger("observer");
    Log.enable("org.netbeans.modules.apisupport.project.universe.ModuleList", Level.ALL);
    
    String mt = "THREAD: Test Watch Dog: testConcurrentScanDeadlock MSG:";
    String wt = "THREAD: worker MSG:";
    String order = 
        mt + "beforeFindOrCreateML" +
        wt + "before PM.mutex" +
        wt + "beforeFindOrCreateML" +
        mt + "runProtected: sync 0";
    Log.controlFlow(LOG, observer, order, 0);
    Thread t = new Thread("worker") {

        @Override
        public void run() {
            try {
                LOG.log(Level.FINE, "before PM.mutex");
                ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                    public Void run() throws Exception {
                        LOG.log(Level.FINE, "beforeFindOrCreateML");
                        ModuleList.findOrCreateModuleListFromNetBeansOrgSources(nbRootFile());
                        LOG.log(Level.FINE, "afterFindOrCreateML");
                        return null;
                    }
                });
            } catch (MutexException ex) {
                throw new RuntimeException(ex);
            }
        }
    };
    t.start();
    LOG.log(Level.FINE, "beforeFindOrCreateML");
    ModuleList.findOrCreateModuleListFromNetBeansOrgSources(nbRootFile());
    LOG.log(Level.FINE, "afterFindOrCreateML");
    t.join();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:Issue167725DeadlockTest.java

示例12: resolveModelSource

import java.util.logging.Logger; //导入方法依赖的package包/类
private ModelSource resolveModelSource(String location, 
ModelSource currentSource, CatalogModel currentCatalog) {
ModelSource ms = null;
try {
    if (location != null) {
	ms = currentCatalog.getModelSource(getURI(location), 
	    currentSource);
    } 
} catch (CatalogModelException nse) {
    // unable to resolve location
    Logger l = Logger.getLogger(AbstractDocumentComponent.class.getName());
    l.log(Level.FINE, nse.getMessage());
}
return ms;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:AbstractDocumentComponent.java

示例13: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute() throws CoreException, IOException, MalformedURLException {
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "executing PostTaskDataCommand for task: {0}", task.getTaskId()); // NOI18N
    }
    AbstractTaskAttachmentHandler taskAttachmentHandler = repositoryConnector.getTaskAttachmentHandler();
    if (!taskAttachmentHandler.canPostContent(taskRepository, task)) {
        throw new IOException("Cannot post attachment for task with id: " + task.getTaskId());
    }
    taskAttachmentHandler.postContent(taskRepository, task, taskAttachmentSource, comment, attAttribute, new NullProgressMonitor());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PostAttachmentCommand.java

示例14: log

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void log(LogRecord[] arr, String loggerName) {
    if (arr == null) {
        return;
    }
    Logger logger = Logger.getLogger(loggerName); // NOI18N
    for (LogRecord r : arr) {
        logger.log(r);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OpenProjectList.java

示例15: instantiate

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public Set instantiate() throws IOException, IllegalArgumentException {
    Set set = delegateIterator.instantiate();
    FileObject template = (FileObject) set.iterator().next();
    if (wiz instanceof TemplateWizard) {
        Logger logger = Logger.getLogger("org.netbeans.ui.metrics.form"); // NOI18N
        LogRecord rec = new LogRecord(Level.INFO, "USG_FORM_CREATED"); // NOI18N
        rec.setLoggerName(logger.getName());
        rec.setParameters(new Object[] { ((TemplateWizard)wiz).getTemplate().getName() });
        logger.log(rec);
    }

    if (specifySuperclass) {
        final String className = template.getName();
        final String superclassName = 
                ((SuperclassWizardPanel) superclassPanel).getSuperclassName();           
        JavaSource js = JavaSource.forFileObject(template);
        js.runModificationTask(new CancellableTask<WorkingCopy>() {
            @Override
            public void cancel() {
            }
            @Override
            public void run(WorkingCopy wcopy) throws Exception {
                wcopy.toPhase(JavaSource.Phase.RESOLVED);
   
                for (Tree t: wcopy.getCompilationUnit().getTypeDecls()) {
                    if (TreeUtilities.CLASS_TREE_KINDS.contains(t.getKind()) && className.equals(((ClassTree) t).getSimpleName().toString())) {
                        ClassTree orig = (ClassTree) t;
                        TreeMaker maker = wcopy.getTreeMaker();
                        TypeElement superclassElm = wcopy.getElements().getTypeElement(superclassName);
                        ExpressionTree extendsTree = superclassElm != null
                            ? maker.QualIdent(superclassElm)
                            : maker.Identifier(superclassName);
                        ClassTree copy = maker.Class(
                            orig.getModifiers(),
                            orig.getSimpleName(),
                            orig.getTypeParameters(),
                            extendsTree,
                            orig.getImplementsClause(),
                            orig.getMembers());
                        wcopy.rewrite(orig, copy);
                        break;
                    }
                }
            }
        }).commit();
    }

    template.setAttribute("justCreatedByNewWizard", Boolean.TRUE); // NOI18N
    
    return set;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:TemplateWizardIterator.java


注:本文中的java.util.logging.Logger.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。