--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In a traditional java/C++/whatever project, this would be trivial. I'd use log4j ( or equivalent ) and setup a log4j.properties file in the classpath.- I want to have appenders to control formatting, timestamps, etc- I want to configure the logging level for each bundle ( including for events mandated by the OSGi spec ) with a properties file.- all bundles shall log to a common file and to the consoleSuppose I have these basic logging requirements:Thanks Peter, I will have a look at the webconsole code to see how it's done.
I'd still like to understand how osgi-pros do logging.
Each class would then call a method logger.debug/info/etc on a static private field, after getting a logger with a specific name.
What would be the functional equivalent way to do this in OSGi ( I mean equivalent from the user's - the java developer's - point of view ) ?
[PS: In the books I have studied so far ( Osgi in practice by Neil Bartlett and OSGi in Action by Hall et al ) there is mention of LogService and LogListener and I have succeeded in using these to get some console output, as shown in my previous question. But this is just a toy and I can't find any useful information on how logging is *used* in *practice*. Certainly, I am not going to roll my own RotateLogFileAppender. The OSGi in Action book covers debugging with eclipse and jdb but my favorite debugging tool is by far an easily configurable and adjustable logging framework.]
osgi.identity;filter:='(osgi.identity=org.apache.sling.commons.log)',\
osgi.identity;filter:='(osgi.identity=org.apache.sling.commons.logservice)',\
org.apache.sling.commons.log;version='[3.0.2,3.0.3)',\
org.apache.sling.commons.logservice;version='[1.0.2,1.0.3)',\
slf4j.api;version='[1.6.2,1.6.3)'
felix.fileinstall.dir=./conf,\
felix.fileinstall.enableConfigSave=false,\
felix.fileinstall.noInitialDelay=true,\
felix.fileinstall.poll=5000,\
-- Ferry Huberts
org.apache.sling.commons.log.LogManager.factory.writer
and org.apache.sling.commons.log.LogManager.factory.config
to receive configurations.org.apache.sling.commons.log.LogManager.factory.writer
-debug.cfgorg.apache.sling.commons.log.LogManager.factory.config
-debug.cfg2) I get the *INFO* entry although I set the level to ERROR.Hi Ferry, thanks for sharing, this works, except that I can't configure the service:The second entry seems to come from somewhere else, since it is not formatted by slf4j. How can I get these messages send to the same logging service (commons ) as the rest ?
There are two issues:
1)
I'm getting these:
02.04.2014 15:31:12.563 *INFO* [FelixDispatchQueue] org.apache.felix.framework FrameworkEvent PACKAGES REFRESHED
[org.apache.felix.framework] FrameworkEvent PACKAGES REFRESHED
I am confused with the names of the config files, you were suggesting
- org.apache.sling.commons.log.LogManager.cfg
- org.apache.sling.commons.log.LogManager.factory.config-debug.txt
- org.apache.sling.commons.log.LogManager.factory.writer-debug.txt
The sling logging website https://sling.apache.org/documentation/development/logging.html says:
... are registered under the PIDsorg.apache.sling.commons.log.LogManager.factory.writer
andorg.apache.sling.commons.log.LogManager.factory.config
to receive configurations.
toegether with the rules for fileinstall https://felix.apache.org/site/apache-felix-file-install.html
I would have guessed something like this:
org.apache.sling.commons.log.LogManager.factory.writer
-debug.cfg
org.apache.sling.commons.log.LogManager.factory.config
-debug.cfg
And I would put this in the config-debug.cfg factory config:
org.apache.sling.commons.log.level=ERROR
org.apache.sling.commons.log.file="log"
The ERROR level is obviously not taken into account in neither solution ( the one you suggested and the one that I would deduce from the docs). Nor is there a "log" file created.
Could you share the contents of your conf files ?
# Sets the initial logging level of the root logger. This may be any of the
# defined logging levels DEBUG, INFO, WARN, ERROR and FATAL.
# Default: INFO
org.apache.sling.commons.log.level=WARN
# Sets the log file to which log messages are written. If this property is
# empty or missing, log messages are written to System.out.
# Default: undefined
org.apache.sling.commons.log.file=./log/myapp.log
# The number of rotated files to keep.
# Default: 5
org.apache.sling.commons.log.file.number=5
# Defines how the log file is rotated (by schedule or by size) and when to
# rotate. See the section Log File Rotation at
# http://sling.apache.org/documentation/development/logging.html for full
# details on log file rotation.
# Default: '.'yyyy-MM-dd
org.apache.sling.commons.log.file.size=10M
# The java.util.MessageFormat pattern to use for formatting log messages with
# the root logger. This is a java.util.MessageFormat pattern supporting up to
# six arguments:
# {0} The timestamp of type java.util.Date,
# {1} the log marker,
# {2} the name of the current thread,
# {3} the name of the logger,
# {4} the debug level,
# {5} the actual debug message
# If the log call includes a Throwable, the stacktrace is just appended to the
# message regardless of the pattern.
# Default: {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}
org.apache.sling.commons.log.pattern={0,date,yyyyMMdd HH:mm:ss.SSS} *{4}* [{2}] {3} : {5}
# Enables the java.util.logging support.
# Default: n/a
org.apache.sling.commons.log.julenabled=true
# Path for the Logback config file which would be used to configure logging.
# If the path is not absolute then it would be resolved against Sling Home
# Default: n/a
#org.apache.sling.commons.log.configurationFile
# Boolean property to control packaging data support of Logback.
# See [Packaging Data][11] section of Logback for more details
# Default: true
#org.apache.sling.commons.log.packagingDataEnabled
# Sets the logging level of the loggers. This may be any of the defined logging
# levels DEBUG, INFO, WARN, ERROR and FATAL.
# Default: INFO
org.apache.sling.commons.log.level=DEBUG
# Sets the log file to which log messages are written. If this property is
# empty or missing, log messages are written to System.out. This property
# should refer to the file name of a configured Log Writer. If no Log Writer is
# configured with the same file name an implicit Log Writer configuration with
# default configuration is created.
# Default: undefined
org.apache.sling.commons.log.file=./log/myapp-debug.log
# The java.util.MessageFormat pattern to use for formatting log messages with
# the root logger. This is a java.util.MessageFormat pattern supporting up to
# six arguments:
# {0} The timestamp of type java.util.Date,
# {1} the log marker,
# {2} the name of the current thread,
# {3} the name of the logger,
# {4} the debug level,
# {5} the actual debug message
# If the log call includes a Throwable, the stacktrace is just appended to the
# message regardless of the pattern.
# Default: {0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}]() {3} {5}
org.apache.sling.commons.log.pattern={0,date,yyyyMMdd HH:mm:ss.SSS} *{4}* [{2}] {3} : {5}
# A list of logger names to which this configuration applies.
# Default: --
org.apache.sling.commons.log.names=nl.pelagic
# Sets the log file to which log messages are written. If this property is
# empty or missing, log messages are written to System.out.
# Default: undefined
org.apache.sling.commons.log.file=./log/myapp-debug.log
# The number of rotated files to keep.
# Default: 5
org.apache.sling.commons.log.file.number=5
# Defines how the log file is rotated (by schedule or by size) and when to
# rotate. See the section Log File Rotation at
# http://sling.apache.org/documentation/development/logging.html for full
# details on log file rotation.
# Default: '.'yyyy-MM-dd
org.apache.sling.commons.log.file.size=10M