• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Level类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.logmanager.Level的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Level类属于org.jboss.logmanager包,在下文中一共展示了Level类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: write

import org.jboss.logmanager.Level; //导入依赖的package包/类
private void write(JavaType javaClass) {

        try {
            String dir = this.targetDir + File.separator + javaClass.getPackage().replace(".", File.separator);
            Files.createDirectories(Paths.get(dir));

            Path fileName = Paths.get(dir + File.separator + javaClass.getName() + ".java");
            if (Files.exists(fileName)) {
                System.err.println("File already exists, will be replaced: " + fileName);
            }

            Files.write(fileName, javaClass.toString().getBytes());

        } catch (IOException e) {
            log.log(Level.ERROR, "Failed to persist class", e);
        }

    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:19,代码来源:Generator.java


示例2: main

import org.jboss.logmanager.Level; //导入依赖的package包/类
public static void main(String[] args) throws MalformedURLException {

        // 2. Specify the alternate log manager as a system property
        System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
        
        // 3. Specify a system property point to logging.properties(optional, if not set, a configuration locator will find 'logging.properties' in the class path)
        String propUrl = JBossLogManagerExample.class.getClassLoader().getResource("logging.properties").toString();
        System.out.println(propUrl);
        System.setProperty("logging.configuration", propUrl);
        
        // 4. Initialize a Logger
        Logger logger = Logger.getLogger(JBossLogManagerExample.class.getName());
        
        // 5. logging the message
        logger.log(Level.TRACE,"TRACE Message");
        logger.log(Level.DEBUG,"DEBUG Message");
        logger.log(Level.INFO,"INFO Message");
        logger.log(Level.WARN,"WARN Message");
        logger.log(Level.ERROR,"Error Message");
        logger.log(Level.FATAL,"FATAL Message");
    }
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:22,代码来源:JBossLogManagerExample.java


示例3: getStdioContext

import org.jboss.logmanager.Level; //导入依赖的package包/类
@Override
public StdioContext getStdioContext() {
    final LogContext logContext = LogContext.getLogContext();
    final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME);
    StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY);
    if (stdioContext == null) {
        stdioContext = StdioContext.create(
                new NullInputStream(),
                new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO),
                new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR)
        );
        final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext);
        if (appearing != null) {
            stdioContext = appearing;
        }
    }
    return stdioContext;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:LogContextStdioContextSelector.java


示例4: writeLogItem

import org.jboss.logmanager.Level; //导入依赖的package包/类
@Override
void writeLogItem(String formattedItem) throws IOException {
    boolean reconnect =  isReconnect();
    if (!reconnect) {
        handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName()));
        errorManager.getAndThrowError();
    } else {
        ControllerLogger.MGMT_OP_LOGGER.attemptingReconnectToSyslog(name, reconnectTimeout);
        try {
            // Reinitialise the delegating syslog handler if required, if we're already connected we don't need to
            // establish a new connection
            if (!connected) {
                stop();
                initialize();
            }
            handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName()));
            errorManager.getAndThrowError();
            lastErrorTime = -1;
        } catch (Exception e) {
            // A failure has occurred and initialization should be reattempted
            connected = false;
            lastErrorTime = System.currentTimeMillis();
            errorManager.throwAsIoOrRuntimeException(e);
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:SyslogAuditLogHandler.java


示例5: getExecutionBuilderFromRMIRegistry

import org.jboss.logmanager.Level; //导入依赖的package包/类
private static ExecutionBuilder getExecutionBuilderFromRMIRegistry()
{
    try
    {
        Registry registry = LocateRegistry.getRegistry(PORT);
        ExecutionBuilder executionBuilder = (ExecutionBuilder) registry.lookup(ExecutionBuilder.LOOKUP_NAME);
        executionBuilder.clear();
        return executionBuilder;
    }
    catch (RemoteException | NotBoundException e)
    {
        LOG.log(Level.SEVERE, e.getMessage(), e);
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:windup,项目名称:windup,代码行数:17,代码来源:ExecutionBuilderTest.java


示例6: format

import org.jboss.logmanager.Level; //导入依赖的package包/类
public String format(LogRecord record) {
	final DateFormat df = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss.SSS");
	StringBuilder builder = new StringBuilder();
	builder.append("[").append(df.format(System.currentTimeMillis())).append("] ");
	builder.append("[").append(record.getLevel() == Level.WARNING ? "WARN" : "INFO").append("] ");
	builder.append(formatMessage(record)).append('\n');
	return builder.toString();
}
 
开发者ID:iotracks,项目名称:iofabric,代码行数:9,代码来源:LogFormatter.java


示例7: shutdown

import org.jboss.logmanager.Level; //导入依赖的package包/类
public void shutdown() {
    try {
        client.close();
    } catch (IOException e) {
        log.log(Level.ERROR, e.getMessage());
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:8,代码来源:Generator.java


示例8: main

import org.jboss.logmanager.Level; //导入依赖的package包/类
/**
 * The main method.
 *
 * @param args the command-line arguments
 */
public static void main(String[] args) throws IOException {
    MDC.put("process", "host controller");


    // Grab copies of our streams.
    final InputStream in = System.in;
    //final PrintStream out = System.out;
    //final PrintStream err = System.err;

    byte[] authKey = new byte[ProcessController.AUTH_BYTES_ENCODED_LENGTH];
    try {
        StreamUtils.readFully(new Base64InputStream(System.in), authKey);
    } catch (IOException e) {
        STDERR.println(HostControllerLogger.ROOT_LOGGER.failedToReadAuthenticationKey(e));
        fail();
        return;
    }

    // Make sure our original stdio is properly captured.
    try {
        Class.forName(ConsoleHandler.class.getName(), true, ConsoleHandler.class.getClassLoader());
    } catch (Throwable ignored) {
    }

    // Install JBoss Stdio to avoid any nasty crosstalk.
    StdioContext.install();
    final StdioContext context = StdioContext.create(
        new NullInputStream(),
        new LoggingOutputStream(Logger.getLogger("stdout"), Level.INFO),
        new LoggingOutputStream(Logger.getLogger("stderr"), Level.ERROR)
    );
    StdioContext.setStdioContextSelector(new SimpleStdioContextSelector(context));

    create(args, new String(authKey, Charset.forName("US-ASCII")));

    while (in.read() != -1) {}
    exit();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:44,代码来源:Main.java


示例9: clearLogContext

import org.jboss.logmanager.Level; //导入依赖的package包/类
/**
 * Attempts to clear the global log context used for embedded servers.
 */
static synchronized void clearLogContext() {
    final LogContext embeddedLogContext = Holder.LOG_CONTEXT;
    // Remove the configurator and clear the log context
    final Configurator configurator = embeddedLogContext.getLogger("").detach(Configurator.ATTACHMENT_KEY);
    // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
    if (configurator instanceof PropertyConfigurator) {
        final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
        clearLogContext(logContextConfiguration);
    } else if (configurator instanceof LogContextConfiguration) {
        clearLogContext((LogContextConfiguration) configurator);
    } else {
        // Remove all the handlers and close them as well as reset the loggers
        final List<String> loggerNames = Collections.list(embeddedLogContext.getLoggerNames());
        for (String name : loggerNames) {
            final Logger logger = embeddedLogContext.getLoggerIfExists(name);
            if (logger != null) {
                final Handler[] handlers = logger.clearHandlers();
                if (handlers != null) {
                    for (Handler handler : handlers) {
                        handler.close();
                    }
                }
                logger.setFilter(null);
                logger.setUseParentFilters(false);
                logger.setUseParentHandlers(true);
                logger.setLevel(Level.INFO);
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:34,代码来源:EmbeddedLogContext.java


示例10: testStartStopAndCleanupIDs

import org.jboss.logmanager.Level; //导入依赖的package包/类
/**
 * Start / stopping the server shouldn't generate any errors.
 * Also it shouldn't bloat the journal with lots of IDs (it should do some cleanup when possible)
 * <br>
 * This is also validating that the same server could be restarted after stopped
 *
 * @throws Exception
 */
@Test
public void testStartStopAndCleanupIDs() throws Exception {
   AssertionLoggerHandler.clear();
   AssertionLoggerHandler.startCapture();
   try {
      ActiveMQServer server = null;

      for (int i = 0; i < 50; i++) {
         server = createServer(true, false);
         server.start();
         server.fail(false);
      }

      // There shouldn't be any error from starting / stopping the server
      assertFalse("There shouldn't be any error for just starting / stopping the server", AssertionLoggerHandler.hasLevel(Level.ERROR));
      assertFalse(AssertionLoggerHandler.findText("AMQ224008"));

      HashMap<Integer, AtomicInteger> records = this.internalCountJournalLivingRecords(server.getConfiguration(), false);

      AtomicInteger recordCount = records.get((int) JournalRecordIds.ID_COUNTER_RECORD);

      assertNotNull(recordCount);

      // The server should remove old IDs from the journal
      assertTrue("The server should cleanup after IDs on the bindings record. It left " + recordCount +
                    " ids on the journal", recordCount.intValue() < 5);

      System.out.println("RecordCount::" + recordCount);

      server.start();

      records = this.internalCountJournalLivingRecords(server.getConfiguration(), false);

      recordCount = records.get((int) JournalRecordIds.ID_COUNTER_RECORD);

      assertNotNull(recordCount);

      System.out.println("Record count with server started: " + recordCount);

      assertTrue("If this is zero it means we are removing too many records", recordCount.intValue() != 0);

      server.stop();

   } finally {
      AssertionLoggerHandler.stopCapture();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:56,代码来源:SimpleStartStopTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SmartThriftClient类代码示例发布时间:2022-05-22
下一篇:
Java FlatXmlWriter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap