org.apache.logging.log4j.simple.SimpleLogger Java Examples
The following examples show how to use
org.apache.logging.log4j.simple.SimpleLogger.
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: Logging.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static org.apache.logging.log4j.Level getLevel(org.apache.logging.log4j.Logger logger) { if(logger instanceof org.apache.logging.log4j.core.Logger) { return ((org.apache.logging.log4j.core.Logger) logger).getLevel(); } else if(logger instanceof SimpleLogger) { return ((SimpleLogger) logger).getLevel(); } else { return null; } }
Example #2
Source File: Logging.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static void setLevel(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level level) { if(logger instanceof org.apache.logging.log4j.core.Logger) { ((org.apache.logging.log4j.core.Logger) logger).setLevel(level); } else if(logger instanceof SimpleLogger) { ((SimpleLogger) logger).setLevel(level); } }
Example #3
Source File: LoggerUtil.java From Javacord with Apache License 2.0 | 5 votes |
/** * Get or create a logger with the given name. * * @param name The name of the logger. * @return The logger with the given name. */ public static Logger getLogger(String name) { AtomicBoolean logWarning = new AtomicBoolean(false); initialized.updateAndGet(initialized -> { if (!initialized && !ProviderUtil.hasProviders()) { noLogger.set(true); logWarning.set(true); } return true; }); if (noLogger.get()) { return loggers.computeIfAbsent(name, key -> { Level level = FallbackLoggerConfiguration.isTraceEnabled() ? Level.TRACE : (FallbackLoggerConfiguration.isDebugEnabled() ? Level.DEBUG : Level.INFO); Logger logger = new SimpleLogger(name, level, true, false, true, true, "yyyy-MM-dd HH:mm:ss.SSSZ", null, new PropertiesUtil(new Properties()), System.out); if (logWarning.get()) { logger.info("No Log4j2 compatible logger was found. Using default Javacord implementation!"); } return new PrivacyProtectionLogger(logger); }); } else { return new PrivacyProtectionLogger(LogManager.getLogger(name)); } }
Example #4
Source File: Log4j2Logger.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
@Override public void setLevel(final Level newLevel) throws SecurityException { if (org.apache.logging.log4j.core.Logger.class.isInstance(log)) { org.apache.logging.log4j.core.Logger.class.cast(log).setLevel(TO_LOG4J.get(newLevel)); } else if (StatusLogger.class.isInstance(log)) { StatusLogger.class.cast(log).setLevel(TO_LOG4J.get(newLevel)); } else if (SimpleLogger.class.isInstance(log)) { SimpleLogger.class.cast(log).setLevel(TO_LOG4J.get(newLevel)); } // else ExtendedLoggerWrapper: ignore for now. we could do reflection if we need it }
Example #5
Source File: LoggerUtil.java From Javacord with Apache License 2.0 | 5 votes |
/** * Get or create a logger with the given name. * * @param name The name of the logger. * @return The logger with the given name. */ public static Logger getLogger(String name) { AtomicBoolean logWarning = new AtomicBoolean(false); initialized.updateAndGet(initialized -> { if (!initialized && !ProviderUtil.hasProviders()) { noLogger.set(true); logWarning.set(true); } return true; }); if (noLogger.get()) { return loggers.computeIfAbsent(name, key -> { Level level = FallbackLoggerConfiguration.isTraceEnabled() ? Level.TRACE : (FallbackLoggerConfiguration.isDebugEnabled() ? Level.DEBUG : Level.INFO); Logger logger = new SimpleLogger(name, level, true, false, true, true, "yyyy-MM-dd HH:mm:ss.SSSZ", null, new PropertiesUtil(new Properties()), System.out); if (logWarning.get()) { logger.info("No Log4j2 compatible logger was found. Using default Javacord implementation!"); } return new PrivacyProtectionLogger(logger); }); } else { return new PrivacyProtectionLogger(LogManager.getLogger(name)); } }
Example #6
Source File: StatusLogger.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private StatusLogger(final String name, final MessageFactory messageFactory) { super(name, messageFactory); final String dateFormat = PROPS.getStringProperty(STATUS_DATE_FORMAT, Strings.EMPTY); final boolean showDateTime = !Strings.isEmpty(dateFormat); this.logger = new SimpleLogger("StatusLogger", Level.ERROR, false, true, showDateTime, false, dateFormat, messageFactory, PROPS, System.err); this.listenersLevel = Level.toLevel(DEFAULT_STATUS_LEVEL, Level.WARN).intLevel(); // LOG4J2-1813 if system property "log4j2.debug" is defined, print all status logging if (isDebugPropertyEnabled()) { logger.setLevel(Level.TRACE); } }