本文整理了Java中org.apache.felix.framework.Logger
类的一些代码示例,展示了Logger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger
类的具体详情如下:
包路径:org.apache.felix.framework.Logger
类名称:Logger
[英]This class mimics the standard OSGi LogService interface. An instance of this class is used by the framework for all logging. By default this class logs messages to standard out. The log level can be set to control the amount of logging performed, where a higher number results in more logging. A log level of zero turns off logging completely.
The log levels match those specified in the OSGi Log Service (i.e., 1 = error, 2 = warning, 3 = information, and 4 = debug). The default value is 1.
[中]此类模仿标准OSGi LogService接口。这个类的一个实例被框架用于所有日志记录。默认情况下,此类将消息记录到标准输出。可以设置日志级别以控制执行的日志记录量,其中,更高的日志记录数会导致更多日志记录。日志级别为零将完全关闭日志记录。
日志级别与OSGi日志服务中指定的级别匹配(即,1=错误,2=警告,3=信息,4=调试)。默认值为1。
代码示例来源:origin: jawi/ols
private Map<String, Object> createConfig()
{
this.fwLogger = new Logger();
this.fwLogger.setLogger( this );
final String logLevel = "" + Math.min( 4, this.options.logLevel );
final Map<String, Object> config = new HashMap<String, Object>();
config.put( Constants.FRAMEWORK_BOOTDELEGATION, "com.yourkit.*,com.sun.*,sun.*,apple.*,com.apple.*" );
config.put( Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
"com.apple.mrj,com.apple.eawt,javax.swing,javax.media.jai,org.osgi.service.cm" );
// Issue #36: explicitly set the location to the bundle cache directory,
// otherwise it is created /relatively/ to the current working directory,
// which is problematic when you start the client with a relative path...
config.put( Constants.FRAMEWORK_STORAGE, this.options.cacheDir.getPath() );
if ( this.options.cleanCache )
{
config.put( Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT );
}
// Felix specific configuration options...
config.put( FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, Arrays.asList( new HostActivator() ) );
config.put( FelixConstants.LOG_LEVEL_PROP, logLevel );
config.put( FelixConstants.LOG_LOGGER_PROP, this.fwLogger );
config.put( "nl.lxtreme.ols.config.dir", this.options.pluginDir.getAbsolutePath() );
return config;
}
代码示例来源:origin: org.jboss.arquillian.container/arquillian-container-felix-embedded
@Override
public void log(Level level, String message, Throwable th) {
switch (level) {
case DEBUG:
logger.log(Logger.LOG_DEBUG, message, th);
break;
case INFO:
logger.log(Logger.LOG_INFO, message, th);
break;
case WARN:
logger.log(Logger.LOG_WARNING, message, th);
break;
case ERROR:
logger.log(Logger.LOG_ERROR, message, th);
break;
}
}
};
代码示例来源:origin: apache/felix
protected void _log(
Bundle bundle, ServiceReference sr, int level,
String msg, Throwable throwable)
{
if (getLogLevel() >= level)
{
// Default logging action.
doLog(bundle, sr, level, msg, throwable);
}
}
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
private void _log(ServiceReference sr, int level, String msg, Throwable throwable)
{
// Save our own copy just in case it changes. We could try to do
// more conservative locking here, but let's be optimistic.
Object[] logger = m_logger;
if (m_logLevel >= level)
{
// Use the log service if available.
if (logger != null)
{
_logReflectively(logger, sr, level, msg, throwable);
}
// Otherwise, default logging action.
else
{
doLog(sr, level, msg, throwable);
}
}
}
代码示例来源:origin: org.apache.sling/maven-launchpad-plugin
Logger logger = new Logger();
logger.setLogLevel(Logger.LOG_ERROR);
代码示例来源:origin: orbisgis/orbisgis
/**
* Create minimal resource inside an empty workspace folder
* @param workspaceFolder
* @param version_major
* @param version_minor
* @param version_revision
* @param version_qualifier
* @throws IOException Error while writing files or the folder is not empty
*/
public static void initWorkspaceFolder(File workspaceFolder, int version_major, int version_minor,
int version_revision, String version_qualifier) throws IOException {
if(!workspaceFolder.exists()) {
if(!workspaceFolder.mkdirs()) {
throw new IOException("Cannot create workspace directory");
}
}
File[] files = workspaceFolder.listFiles();
if (files != null && files.length != 0) {
// This method must be called with empty folder only
throw new IOException("Workspace folder must be empty");
}
CoreWorkspaceImpl coreWorspace = new CoreWorkspaceImpl(version_major, version_minor, version_revision,
version_qualifier, new Logger());
coreWorspace.setWorkspaceFolder(workspaceFolder.getAbsolutePath());
coreWorspace.writeVersionFile();
coreWorspace.writeUriFile();
}
代码示例来源:origin: apache/felix
private void markResolvedRevisions(Map<Resource, List<Wire>> wireMap)
throws ResolveException
boolean debugLog = m_felix.getLogger().getLogLevel() >= Logger.LOG_DEBUG;
m_felix.getLogger().log(
Logger.LOG_DEBUG,
"FRAGMENT WIRE: " + rw.toString());
m_felix.getLogger().log(Logger.LOG_DEBUG, "WIRE: " + rw.toString());
m_felix.getLogger().log(
Logger.LOG_ERROR,
rte.getMessage(), ex2);
revision, null);
re.initCause(ex);
m_felix.getLogger().log(
Logger.LOG_ERROR,
re.getMessage(), ex);
代码示例来源:origin: apache/felix
m_logger.log(
Logger.LOG_ERROR,
"Unable to close input stream.", ex);
m_logger.log(bundle,
Logger.LOG_ERROR,
"Could not remove from cache.", ex1);
m_logger.log(bundle,
Logger.LOG_ERROR,
"Unable to close input stream.", ex);
m_logger.doLog(
hook.getBundle(),
hook,
代码示例来源:origin: apache/felix
public final void log(Bundle bundle, int level, String msg)
{
_log(bundle, null, level, msg, null);
}
代码示例来源:origin: apache/felix
if (m_logger.getLogLevel() >= Logger.LOG_DEBUG)
代码示例来源:origin: org.apache.sling/org.apache.sling.launchpad.base
logger.setLogLevel(Logger.LOG_ERROR);
if ( System.getProperty(PROP_BOOT_LOG_LEVEL) != null ) {
try {
logger.setLogLevel(
Integer.parseInt(System.getProperty(PROP_BOOT_LOG_LEVEL)));
} catch (final NumberFormatException ex) {
代码示例来源:origin: apache/felix
protected void doLog(
Bundle bundle, ServiceReference sr, int level,
String msg, Throwable throwable)
{
StringBuilder s = new StringBuilder();
if (sr != null)
{
s.append("SvcRef ").append(sr).append(" ").append(msg);
}
else if (bundle != null)
{
s.append("Bundle ").append(bundle.toString()).append(" ").append(msg);
}
else
{
s.append(msg);
}
if (throwable != null)
{
s.append(" (").append(throwable).append(")");
}
doLog(level, s.toString(), throwable);
}
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
/**
* This method is called when the system bundle context is set;
* it simply adds a service listener so that the system bundle can track
* log services to be used as the back end of the logging mechanism. It also
* attempts to get an existing log service, if present, but in general
* there will never be a log service present since the system bundle is
* started before every other bundle.
**/
private synchronized void startListeningForLogService()
{
// Add a service listener for log services.
try
{
m_context.addServiceListener(
this, "(objectClass=org.osgi.service.log.LogService)");
}
catch (InvalidSyntaxException ex) {
// This will never happen since the filter is hard coded.
}
// Try to get an existing log service.
m_logRef = m_context.getServiceReference("org.osgi.service.log.LogService");
// Get the service object if available and set it in the logger.
if (m_logRef != null)
{
setLogger(m_context.getService(m_logRef));
}
}
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
m_logger = new Logger();
m_logger.setLogLevel(
Integer.parseInt(
(String) m_configMutableMap.get(FelixConstants.LOG_LEVEL_PROP)));
代码示例来源:origin: org.orbisgis/orbisgis-core
org.apache.felix.framework.Logger logger = new org.apache.felix.framework.Logger();
代码示例来源:origin: apache/felix
public final void log(ServiceReference sr, int level, String msg)
{
_log(null, sr, level, msg, null);
}
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
if (m_logger.getLogLevel() >= Logger.LOG_DEBUG)
代码示例来源:origin: apache/felix
m_logger.doLog(
hook.getBundle(),
hook,
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
setLogger(m_context.getService(m_logRef));
setLogger(m_context.getService(m_logRef));
setLogger(m_context.getService(m_logRef));
setLogger(null);
代码示例来源:origin: org.apache.servicemix.kernel/org.apache.servicemix.kernel.main
private void log(int flag, String msg, Throwable th)
{
if (m_logger == null)
{
System.out.println(msg + ": " + th);
}
else
{
m_logger.log(flag, msg, th);
}
}
内容来源于网络,如有侵权,请联系作者删除!