I think you should place your logback.xml into src/main/resources.
You have at the top of the maven project and it will never get included in the jar that maven generates.
Give that a try.
Printable View
I think you should place your logback.xml into src/main/resources.
You have at the top of the maven project and it will never get included in the jar that maven generates.
Give that a try.
Well I used Include-Resource option of maven-bundle-plugin to put logback.xml in jar. Unzip jar file from target dir, logback.xml included in it.
Ok, you right :).
This is what I did in logback.xml:
Result in serviceability/logs/log.log and /logs/dm-server/log.log are similarCode:<logger level="DEBUG" additivity="false" name="com.log.test">
<appender-ref ref="STDOUT"/>
<appender-ref ref="FILE_SERVICE"/>
</logger>
<!--<root level="DEBUG">-->
<!--<!– The following level element is not necessary since the –>-->
<!--<!– level of the root level is set to DEBUG by default. –>-->
<!--<!–<level value="DEBUG"/>–>-->
<!--<appender-ref ref="STDOUT"/>-->
<!--<appender-ref ref="FILE_SERVICE"/>-->
<!--</root>-->
As far as why it is not writing to the file that you want it to write to - not sure. Try to put in a debugger and see.Code:[2010-04-14 11:22:47.804] fs-watcher com.log.test.LogTestActivator Hello world
[2010-04-14 11:22:47.855] start-signalling-1 com.springsource.osgi.medic.eventlog.default DE0005I Started bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:32.963] fs-watcher com.springsource.osgi.medic.eventlog.default HD0001I Hot deployer processing 'MODIFIED' event for file 'log-test-1.0.0.jar'.
[2010-04-14 11:24:33.061] fs-watcher com.springsource.osgi.medic.eventlog.default DE0007I Refreshing bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:33.117] fs-watcher com.springsource.osgi.medic.eventlog.default DE0010I Stopping bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:33.118] fs-watcher com.log.test.LogTestActivator Goodbye World
[2010-04-14 11:24:33.125] fs-watcher com.springsource.osgi.medic.eventlog.default DE0011I Stopped bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:33.506] fs-watcher com.springsource.osgi.medic.eventlog.default DE0004I Starting bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:33.510] fs-watcher com.log.test.LogTestActivator Hello world
[2010-04-14 11:24:33.516] start-signalling-1 com.springsource.osgi.medic.eventlog.default DE0005I Started bundle 'log-test' version '1.0.0'.
[2010-04-14 11:24:33.529] fs-watcher com.springsource.osgi.medic.eventlog.default DE0008I Refreshed bundle 'log-test' version '1.0.0'.
You can do it with a -debug flag for the startup.bat/sh. Debugger will start up on port 8000 by default.
Good luck.
How I suppose to know, if behavior is incorrect. Logging is working, no exception throws.
The only one problem is issue with not using my custom config.
I'm not sure if I be able to catch moment of not loading my config even in debug mode...
I did not get a chance to debug through the logging code. I noticed that you are logging at the "error" level. dm-server root logger is at the warn level that is the reason I saw log output in the dm-server logs.
When tuning down log level in your example code to "info", dm server did not pick up logback.xml from the bundle. I am not so sure now that embedding logback.xml works.
I guess the only way is to modify DM_HOME/config/serviceability.xml (this is renamed logback.xml for the whole server) to add your custom configuration there.
Is there a reason why you don't want to modify that file?
I also would prefer to include logging configuration in my application bundles without touching the server's config file, since it's specific to the application.
I've spend hours on researching until I came across this thread.
If anyone knows how to deal with this I would appreciate it.
Ivan, you can try next steps:
1. Remove slf4j.nop bundle from repository/ext folder.
2. Add import of ch.qos.logback.classic and ch.qos.logback.core packages in your's application bundle.
3. Put logback.xml in bundle classpath of your application's bundle.