Java Code Examples for org.apache.log4j.Level#INFO
The following examples show how to use
org.apache.log4j.Level#INFO .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandLine.java From ofexport2 with Apache License 2.0 | 6 votes |
protected void setLogLevel(String logLevel) { Level level = Level.DEBUG; switch (logLevel.toLowerCase()) { case "debug": level = Level.DEBUG; break; case "info": level = Level.INFO; break; case "warn": level = Level.WARN; break; case "error": level = Level.ERROR; break; } org.apache.log4j.Logger.getLogger("org.psidnell").setLevel(level); LOGGER.debug("Log level is " + logLevel); }
Example 2
Source File: LoggingEventTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Tests LoggingEvent.getLocationInfo() when no FQCN is specified. * See bug 41186. */ public void testLocationInfoNoFQCN() { Category root = Logger.getRootLogger(); Priority level = Level.INFO; LoggingEvent event = new LoggingEvent( null, root, 0L, level, "Hello, world.", null); LocationInfo info = event.getLocationInformation(); // // log4j 1.2 returns an object, its layout doesn't check for nulls. // log4j 1.3 returns a null. // assertNotNull(info); if (info != null) { assertEquals("?", info.getLineNumber()); assertEquals("?", info.getClassName()); assertEquals("?", info.getFileName()); assertEquals("?", info.getMethodName()); } }
Example 3
Source File: FragmenterResource.java From pxf with Apache License 2.0 | 6 votes |
private void logFragmentStatistics(Level level, RequestContext context, List<Fragment> fragments) { int numberOfFragments = fragments.size(); SessionId session = new SessionId(context.getSegmentId(), context.getTransactionId(), context.getUser(), context.getServerName()); long elapsedMillis = System.currentTimeMillis() - startTime; if (level == Level.INFO) { LOG.info("{} returns {} fragment{} for path {} in {} ms for {} [profile {} filter is{} available]", context.getFragmenter(), numberOfFragments, numberOfFragments == 1 ? "" : "s", context.getDataSource(), elapsedMillis, session, context.getProfile(), context.hasFilter() ? "" : " not"); } else if (level == Level.DEBUG) { LOG.debug("{} returns {} fragment{} for path {} in {} ms for {} [profile {} filter is{} available]", context.getFragmenter(), numberOfFragments, numberOfFragments == 1 ? "" : "s", context.getDataSource(), elapsedMillis, session, context.getProfile(), context.hasFilter() ? "" : " not"); } }
Example 4
Source File: TajoLogEventCounter.java From tajo with Apache License 2.0 | 5 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); String levelStr = level.toString(); if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) { counts.incr(INFO); } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) { counts.incr(WARN); } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) { counts.incr(ERROR); } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) { counts.incr(FATAL); } }
Example 5
Source File: LoggingEventTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Serialize a logging event with ndc. * @throws Exception if exception during test. * */ public void testSerializationNDC() throws Exception { Logger root = Logger.getRootLogger(); NDC.push("ndc test"); LoggingEvent event = new LoggingEvent( root.getClass().getName(), root, Level.INFO, "Hello, world.", null); // event.prepareForDeferredProcessing(); int[] skip = new int[] { 352, 353, 354, 355, 356 }; SerializationTestHelper.assertSerializationEquals( "witness/serialization/ndc.bin", event, skip, 237); }
Example 6
Source File: NotRuleTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
/** * Test deserialized Not. */ @Test public void test5() throws IOException, ClassNotFoundException { Stack<Object> stack = new Stack<>(); stack.push(LevelEqualsRule.getRule("INFO")); Rule rule = (Rule) SerializationTestHelper.serializeClone(NotRule.getRule(stack)); AssertJUnit.assertEquals(0, stack.size()); Calendar cal = new GregorianCalendar(2008, 4, 21, 0, 45, 44); LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger", Logger.getRootLogger(), cal.getTimeInMillis(), Level.INFO, "Hello, World", null); AssertJUnit.assertFalse(rule.evaluate(Log4jUtil.translateLog4j(event), null)); }
Example 7
Source File: XMLLayoutTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Tests formatted results. * @throws Exception if parser can not be constructed or source is not a valid XML document. */ public void testFormat() throws Exception { Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest"); LoggingEvent event = new LoggingEvent( "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null); XMLLayout layout = (XMLLayout) createLayout(); String result = layout.format(event); Element parsedResult = parse(result); checkEventElement(parsedResult, event); int childElementCount = 0; for ( Node node = parsedResult.getFirstChild(); node != null; node = node.getNextSibling()) { switch (node.getNodeType()) { case Node.ELEMENT_NODE: childElementCount++; checkMessageElement((Element) node, "Hello, World"); break; case Node.COMMENT_NODE: break; case Node.TEXT_NODE: // should only be whitespace break; default: fail("Unexpected node type"); break; } } assertEquals(1, childElementCount); }
Example 8
Source File: LevelInequalityRuleTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
/** * Tests evaluate of a deserialized clone when level satisfies rule. */ @Test public void test3() throws IOException, ClassNotFoundException { Rule rule = (Rule) SerializationTestHelper.serializeClone(LevelInequalityRule.getRule(">=", "info")); LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger", Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO, "Hello, World", null); AssertJUnit.assertTrue(rule.evaluate(Log4jUtil.translateLog4j(event), null)); }
Example 9
Source File: ExistsRuleTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
/** * getRule with "msg". */ @Test public void test4() { Stack<Object> stack = new Stack<>(); stack.push("msg"); Rule rule = ExistsRule.getRule(stack); AssertJUnit.assertEquals(0, stack.size()); LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger", Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO, "", null); AssertJUnit.assertFalse(rule.evaluate(Log4jUtil.translateLog4j(event), null)); }
Example 10
Source File: MainWindow.java From ripme with MIT License | 5 votes |
private void setLogLevel(String level) { Level newLevel = Level.ERROR; level = level.substring(level.lastIndexOf(' ') + 1); switch (level) { case "Debug": newLevel = Level.DEBUG; break; case "Info": newLevel = Level.INFO; break; case "Warn": newLevel = Level.WARN; break; case "Error": newLevel = Level.ERROR; break; } Logger.getRootLogger().setLevel(newLevel); LOGGER.setLevel(newLevel); ConsoleAppender ca = (ConsoleAppender) Logger.getRootLogger().getAppender("stdout"); if (ca != null) { ca.setThreshold(newLevel); } FileAppender fa = (FileAppender) Logger.getRootLogger().getAppender("FILE"); if (fa != null) { fa.setThreshold(newLevel); } }
Example 11
Source File: EqualsRuleTest.java From otroslogviewer with Apache License 2.0 | 5 votes |
/** * getRule with "msg" should return an EqualsRule. */ @Test public void test5() { Stack<Object> stack = new Stack<>(); stack.push("msg"); stack.push("Hello, World"); Rule rule = EqualsRule.getRule(stack); AssertJUnit.assertEquals(0, stack.size()); LoggingEvent event = new LoggingEvent("org.apache.log4j.Logger", Logger.getRootLogger(), System.currentTimeMillis(), Level.INFO, "Hello, World", null); AssertJUnit.assertTrue(rule.evaluate(Log4jUtil.translateLog4j(event), null)); }
Example 12
Source File: LoggerFactory.java From development with Apache License 2.0 | 5 votes |
/** * Determines the log level represented by the configuration setting. If the * stored value does not match any of the supported log levels, the default * log level INFO will be used. * * @param logLevel * The log level information read from the configuration * settings. * @return The log4j compliant log level to be used. */ private static Level determineLogLevel(String logLevel) { Level level = Level.INFO; if (DEBUG_LOG_LEVEL.equals(logLevel)) { level = Level.DEBUG; } else if (WARN_LOG_LEVEL.equals(logLevel)) { level = Level.WARN; } else if (ERROR_LOG_LEVEL.equals(logLevel)) { level = Level.ERROR; } else if (INFO_LOG_LEVEL.equals(logLevel)) { level = Level.INFO; } return level; }
Example 13
Source File: LoggingEventTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Serialize a simple logging event and check it against * a witness. * @throws Exception if exception during test. */ public void testSerializationSimple() throws Exception { Logger root = Logger.getRootLogger(); LoggingEvent event = new LoggingEvent( root.getClass().getName(), root, Level.INFO, "Hello, world.", null); // event.prepareForDeferredProcessing(); int[] skip = new int[] { 352, 353, 354, 355, 356 }; SerializationTestHelper.assertSerializationEquals( "witness/serialization/simple.bin", event, skip, 237); }
Example 14
Source File: Log4j.java From pegasus with Apache License 2.0 | 5 votes |
/** * Sets the debug level. All those messages are logged which have a level less than equal to the * debug level. In case the boolean info is set, all the info messages are also logged. * * @param level the level to which the debug level needs to be set to. * @param info boolean denoting whether the INFO messages need to be logged or not. */ protected void setLevel(int level, boolean info) { Level l = Level.ALL; switch (level) { case LogManager.FATAL_MESSAGE_LEVEL: l = Level.FATAL; break; case LogManager.ERROR_MESSAGE_LEVEL: l = Level.ERROR; break; case LogManager.WARNING_MESSAGE_LEVEL: l = Level.WARN; break; case LogManager.CONFIG_MESSAGE_LEVEL: l = Level.INFO; break; case LogManager.INFO_MESSAGE_LEVEL: l = Level.INFO; break; case LogManager.DEBUG_MESSAGE_LEVEL: l = Level.DEBUG; break; } mLogger.setLevel(l); }
Example 15
Source File: PLogger.java From tagme with Apache License 2.0 | 4 votes |
public PLogger(Logger log, Step step) { this(log, Level.INFO, step, "items"); }
Example 16
Source File: ConfigManageController.java From wind-im with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST, value = "/updateConfig") @ResponseBody public String updateSiteConfig(HttpServletRequest request, @RequestBody byte[] bodyParam) { try { PluginProto.ProxyPluginPackage pluginPackage = PluginProto.ProxyPluginPackage.parseFrom(bodyParam); String siteUserId = getRequestSiteUserId(pluginPackage); if (!isManager(siteUserId)) { throw new UserPermissionException("Current user is not a manager"); } Map<String, String> dataMap = GsonUtils.fromJson(pluginPackage.getData(), Map.class); logger.info("siteUserId={} update config={}", siteUserId, dataMap); Map<Integer, String> configMap = new HashMap<Integer, String>(); if (StringUtils.isNotEmpty(trim(dataMap.get("site_name")))) { configMap.put(ConfigProto.ConfigKey.SITE_NAME_VALUE, trim(dataMap.get("site_name"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_address")))) { configMap.put(ConfigProto.ConfigKey.SITE_ADDRESS_VALUE, trim(dataMap.get("site_address"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("site_port")))) { configMap.put(ConfigProto.ConfigKey.SITE_PORT_VALUE, trim(dataMap.get("site_port"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("group_members_count")))) { configMap.put(ConfigProto.ConfigKey.GROUP_MEMBERS_COUNT_VALUE, trim(dataMap.get("group_members_count"))); } if (StringUtils.isNotEmpty(trim(dataMap.get("pic_path")))) { configMap.put(ConfigProto.ConfigKey.PIC_PATH_VALUE, trim(dataMap.get("pic_path"))); } if (StringUtils.isNotEmpty(dataMap.get("site_logo"))) { configMap.put(ConfigProto.ConfigKey.SITE_LOGO_VALUE, dataMap.get("site_logo")); } if (StringUtils.isNotEmpty(dataMap.get("uic_status"))) { configMap.put(ConfigProto.ConfigKey.INVITE_CODE_STATUS_VALUE, dataMap.get("uic_status")); } if (StringUtils.isNotEmpty(dataMap.get("realName_status"))) { configMap.put(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE, dataMap.get("realName_status")); } if (StringUtils.isNotEmpty(dataMap.get("u2_encryption_status"))) { configMap.put(ConfigProto.ConfigKey.U2_ENCRYPTION_STATUS_VALUE, dataMap.get("u2_encryption_status")); } if (StringUtils.isNotEmpty(dataMap.get("add_friends_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_FRIEND_REQUEST_VALUE, dataMap.get("add_friends_status")); } if (StringUtils.isNotEmpty(dataMap.get("create_groups_status"))) { configMap.put(ConfigProto.ConfigKey.CONFIG_CREATE_GROUP_VALUE, dataMap.get("create_groups_status")); } if (StringUtils.isNotEmpty(dataMap.get("group_qrcode_expire_time"))) { configMap.put(ConfigProto.ConfigKey.GROUP_QR_EXPIRE_TIME_VALUE, dataMap.get("group_qrcode_expire_time")); } if (StringUtils.isNotEmpty(dataMap.get("push_client_status"))) { configMap.put(ConfigProto.ConfigKey.PUSH_CLIENT_STATUS_VALUE, dataMap.get("push_client_status")); } if (StringUtils.isNotEmpty(dataMap.get("log_level"))) { String logLevel = dataMap.get("log_level"); configMap.put(ConfigProto.ConfigKey.LOG_LEVEL_VALUE, logLevel); Level level = Level.INFO; if ("DEBUG".equalsIgnoreCase(logLevel)) { level = Level.DEBUG; } else if ("ERROR".equalsIgnoreCase(logLevel)) { level = Level.ERROR; } // 更新日志级别 AkxLog4jManager.setLogLevel(level); } // 普通管理员无权限 if (isAdmin(siteUserId) && StringUtils.isNotEmpty(trim(dataMap.get("site_manager")))) { configMap.put(ConfigProto.ConfigKey.SITE_MANAGER_VALUE, trim(dataMap.get("site_manager"))); } if (configManageService.updateSiteConfig(siteUserId, configMap)) { return SUCCESS; } } catch (InvalidProtocolBufferException e) { logger.error("update site config error", e); } catch (UserPermissionException u) { logger.error("update site config error : " + u.getMessage()); return NO_PERMISSION; } return ERROR; }
Example 17
Source File: OptimizerUtils.java From systemds with Apache License 2.0 | 4 votes |
public static Level getDefaultLogLevel() { Level log = Logger.getRootLogger().getLevel(); return (log != null) ? log : Level.INFO; }
Example 18
Source File: StartSomethingProcessor.java From swift-k with Apache License 2.0 | 4 votes |
public Level getSupportedLevel() { return Level.INFO; }
Example 19
Source File: AsyncCoalescingStatisticsAppender.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public AsyncCoalescingStatisticsAppender() { this.downstreamLogLevel = Level.INFO; this.baseImplementation = this.newGenericAsyncCoalescingStatisticsAppender(); this.downstreamAppenders = new AppenderAttachableImpl(); this.shutdownHook = null; }
Example 20
Source File: AbstractRemoteLogProcessor.java From swift-k with Apache License 2.0 | 4 votes |
@Override public Level getSupportedLevel() { return Level.INFO; }