本文整理汇总了Java中org.apache.commons.logging.LogConfigurationException类的典型用法代码示例。如果您正苦于以下问题:Java LogConfigurationException类的具体用法?Java LogConfigurationException怎么用?Java LogConfigurationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogConfigurationException类属于org.apache.commons.logging包,在下文中一共展示了LogConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
/**
* <p>
* Construct (if necessary) and return a <code>Log</code> instance, using
* the factory's current set of configuration attributes.
* </p>
*
* @param name
* Logical name of the <code>Log</code> instance to be returned
* (the meaning of this name is only known to the underlying logging
* implementation that is being wrapped)
*
* @exception LogConfigurationException
* if a suitable <code>Log</code> instance cannot be returned
*/
public Log getInstance(String name) throws LogConfigurationException {
Log instance = loggerMap.get(name);
if (instance != null) {
return instance;
} else {
Log newInstance;
Logger slf4jLogger = LoggerFactory.getLogger(name);
if (slf4jLogger instanceof LocationAwareLogger) {
newInstance = new SLF4JLocationAwareLog((LocationAwareLogger) slf4jLogger);
} else {
newInstance = new SLF4JLog(slf4jLogger);
}
Log oldInstance = loggerMap.putIfAbsent(name, newInstance);
return oldInstance == null ? newInstance : oldInstance;
}
}
示例2: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
public Log getInstance(String name) throws LogConfigurationException
{
String match="";
for (int i=prefixes.size();name!=null && i-->0;)
{
String prefix=(String)prefixes.get(i);
if (name.startsWith(prefix) && prefix.length()>match.length())
match=prefix;
}
if (match.length()>0)
name=match+".*";
// Get value
Object o = attributes.get(name);
// Dereference string attributes
while(o!=null && o instanceof String)
o=attributes.get(o);
// return actual log.
if (o instanceof Log)
return (Log)o;
return log;
}
示例3: getLog
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
private Log getLog(String cat, String suffix) {
if (suffix != null) {
suffix = suffix.replace('.', '-');
suffix = suffix.replace(' ', '-');
cat = cat + "." + suffix;
}
final PrintStream tmpOut = System.out;
final PrintStream tmpErr = System.err;
System.setOut(out);
System.setErr(err);
if (!initialized) {
try {
logFactory = LogFactory.getFactory();
} catch (final LogConfigurationException e) {
e.printStackTrace(System.err);
return null;
}
}
initialized = true;
final Log log = logFactory.getInstance(cat);
System.setOut(tmpOut);
System.setErr(tmpErr);
return log;
}
示例4: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
public Log getInstance(String name)
throws LogConfigurationException
{
Log instance = (Log) this.instances.get(name);
if (instance == null)
{
Logger tempLogger = (Logger) Jdk14Factory.otherLoggerMap.get(name);
if (tempLogger == null)
{
tempLogger = Jdk14Factory.defaultLogger;
}
instance = new MyJdk14Logger(tempLogger);
this.instances.put(name, instance);
}
return instance;
}
示例5: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
/**
* <p>
* Construct (if necessary) and return a <code>Log</code> instance, using
* the factory's current set of configuration attributes.
* </p>
*
* @param name
* Logical name of the <code>Log</code> instance to be returned
* (the meaning of this name is only known to the underlying logging
* implementation that is being wrapped)
*
* @exception LogConfigurationException
* if a suitable <code>Log</code> instance cannot be returned
*/
public Log getInstance(String name) throws LogConfigurationException {
// Log instance = loggerMap.get(name);
// if (instance != null) {
// return instance;
// } else {
// Log newInstance;
// Logger slf4jLogger = org.zollty.log.LogFactory.getLogger(name);
//
// newInstance = new Mlf4jLog(slf4jLogger);
//
// Log oldInstance = loggerMap.putIfAbsent(name, newInstance);
// return oldInstance == null ? newInstance : oldInstance;
// }
return new JrettyCommonsLog( org.jretty.log.LogFactory.getLogger(name) );
}
示例6: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
/**
* Convenience method to derive a name from the specified class and
* call <code>getInstance(String)</code> with it.
* @param clazz Class for which a suitable Log name will be derived
* @param log the cached log instance.
* @return the {@link Log} instance.
*/
@Nullable
protected Log getInstance(@NotNull final Class<?> clazz, @Nullable final Log log)
throws LogConfigurationException
{
@Nullable Log result = log;
@Nullable final LogFactory t_LogFactory = LogFactory.getFactory();
if (t_LogFactory != null)
{
result = t_LogFactory.getInstance(clazz);
}
return result;
}
示例7: CommonsLoggingListener
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
/**
* Creates a <code>CommonsLoggingListener. Initializes its log factory.
* @throws CheckstyleException if if the implementation class is not
* available or cannot be instantiated.
*/
public CommonsLoggingListener() throws CheckstyleException
{
try {
mLogFactory = LogFactory.getFactory();
}
catch (LogConfigurationException e) {
throw new CheckstyleException("log configuration exception", e);
}
mInitialized = true;
}
示例8: Resolver
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
/**
* constructor with <code>SymbolTable</code> to be resolved
*/
public Resolver(SymbolTable symbolTable) {
super(symbolTable);
try {
mLogFactory = LogFactory.getFactory();
}
catch (LogConfigurationException e) {
System.out.println("log configuration exception" + e);
}
mInitialized = true;
}
示例9: followCommonsLog
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
private static void followCommonsLog(CommonsLoggingListener logger, String logName)
throws LogConfigurationException, SecurityException
{
if (registeredLoggers.contains(logName)) //make sure no log is registered twice!
return;
Core.getLogger(CommonsLoggingListener.class.getName()).info("Now listening to " + logName);
registeredLoggers.add(logName);
org.apache.commons.logging.impl.Jdk14Logger lognode = (org.apache.commons.logging.impl.Jdk14Logger) LogFactory.getLog(logName);
lognode.getLogger().addHandler(logger);
}
示例10: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
@Override
public Log getInstance(String name) throws LogConfigurationException {
if (AutoConfigurationReportLoggingInitializer.class.getName().equals(name)) {
return logThreadLocal.get();
}
return new NoOpLog();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:AutoConfigurationReportLoggingInitializerTests.java
示例11: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
public Log getInstance(final String name) throws LogConfigurationException {
Log _logger = __LOGGER_CACHE.get(name);
if (_logger == null) {
_logger = new JCLogger(name);
__LOGGER_CACHE.put(name, _logger);
}
return _logger;
}
示例12: testInitLoggerContextException
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
@Test(expectedExceptions = LogConfigurationException.class)
public void testInitLoggerContextException() throws Throwable {
doReturn(null).when(testling).getConfigFileFromClasspath();
doReturn(null).when(testling).getConfigFile();
testling.initLoggerContext();
}
示例13: getInstance
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
@Override
public Log getInstance(final String name) throws LogConfigurationException {
final ConcurrentMap<String, Log> loggers = getLoggersMap();
if (loggers.containsKey(name)) {
return loggers.get(name);
}
final org.apache.logging.log4j.Logger logger = PrivateManager.getLogger(name);
if (logger instanceof AbstractLogger) {
loggers.putIfAbsent(name, new Log4jLog((AbstractLogger) logger, name));
return loggers.get(name);
}
throw new LogConfigurationException(
"Commons Logging Adapter requires base logging system to extend Log4j AbstractLogger");
}
示例14: getRequestLog
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
public static RequestLog getRequestLog(String name) {
String lookup = serverToComponent.get(name);
if (lookup != null) {
name = lookup;
}
String loggerName = "http.requests." + name;
String appenderName = name + "requestlog";
Log logger = LogFactory.getLog(loggerName);
boolean isLog4JLogger;;
try {
isLog4JLogger = logger instanceof Log4JLogger;
} catch (NoClassDefFoundError err) {
// In some dependent projects, log4j may not even be on the classpath at
// runtime, in which case the above instanceof check will throw
// NoClassDefFoundError.
LOG.debug("Could not load Log4JLogger class", err);
isLog4JLogger = false;
}
if (isLog4JLogger) {
Log4JLogger httpLog4JLog = (Log4JLogger)logger;
Logger httpLogger = httpLog4JLog.getLogger();
Appender appender = null;
try {
appender = httpLogger.getAppender(appenderName);
} catch (LogConfigurationException e) {
LOG.warn("Http request log for " + loggerName
+ " could not be created");
throw e;
}
if (appender == null) {
LOG.info("Http request log for " + loggerName
+ " is not defined");
return null;
}
if (appender instanceof HttpRequestLogAppender) {
HttpRequestLogAppender requestLogAppender
= (HttpRequestLogAppender)appender;
NCSARequestLog requestLog = new NCSARequestLog();
requestLog.setFilename(requestLogAppender.getFilename());
requestLog.setRetainDays(requestLogAppender.getRetainDays());
return requestLog;
}
else {
LOG.warn("Jetty request log for " + loggerName
+ " was of the wrong class");
return null;
}
}
else {
LOG.warn("Jetty request log can only be enabled using Log4j");
return null;
}
}
示例15: getRequestLog
import org.apache.commons.logging.LogConfigurationException; //导入依赖的package包/类
public static RequestLog getRequestLog(String name) {
String lookup = serverToComponent.get(name);
if (lookup != null) {
name = lookup;
}
String loggerName = "http.requests." + name;
String appenderName = name + "requestlog";
Log logger = LogFactory.getLog(loggerName);
if (logger instanceof Log4JLogger) {
Log4JLogger httpLog4JLog = (Log4JLogger)logger;
Logger httpLogger = httpLog4JLog.getLogger();
Appender appender = null;
try {
appender = httpLogger.getAppender(appenderName);
} catch (LogConfigurationException e) {
LOG.warn("Http request log for " + loggerName
+ " could not be created");
throw e;
}
if (appender == null) {
LOG.info("Http request log for " + loggerName
+ " is not defined");
return null;
}
if (appender instanceof HttpRequestLogAppender) {
HttpRequestLogAppender requestLogAppender
= (HttpRequestLogAppender)appender;
NCSARequestLog requestLog = new NCSARequestLog();
requestLog.setFilename(requestLogAppender.getFilename());
requestLog.setRetainDays(requestLogAppender.getRetainDays());
return requestLog;
} else {
LOG.warn("Jetty request log for " + loggerName
+ " was of the wrong class");
return null;
}
}
else {
LOG.warn("Jetty request log can only be enabled using Log4j");
return null;
}
}