I want to enable logging for my unmanaged extensions, which works also fine so far (at least in my unit tests). So I wrote a logback.xml and included it into my package. When I run a unit test (functional test) with a db that will be created on the fly everything works fine, i.e., my logging definitions got recognized and the logging works as expected. Here is an excerpt of the logs where you can see that the different will be registered:
12:07:56,597 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/home/me/git/myproject/target/classes/logback.xml]
12:07:56,598 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
12:07:56,598 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [file:/home/me/git/myproject/target/classes/logback.xml]
12:07:56,598 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/home/me/.m2/repository/org/neo4j/app/neo4j-server/2.0.1/neo4j-server-2.0.1.jar!/logback.xml]
12:07:56,699 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:07:56,700 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,706 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAT]
12:07:56,728 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,757 |-INFO in ch.qos.logback.core.FileAppender[FAT] - File property is set to [logs/myproject/trace/messages.log]
12:07:56,757 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,757 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAD]
12:07:56,758 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,759 |-INFO in ch.qos.logback.core.FileAppender[FAD] - File property is set to [logs/myproject/debug/messages.log]
12:07:56,759 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,759 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAI]
12:07:56,759 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,760 |-INFO in ch.qos.logback.core.FileAppender[FAI] - File property is set to [logs/myproject/info/messages.log]
12:07:56,760 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,760 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAW]
12:07:56,761 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,761 |-INFO in ch.qos.logback.core.FileAppender[FAW] - File property is set to [logs/myproject/warn/messages.log]
12:07:56,761 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,761 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAE]
12:07:56,762 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,762 |-INFO in ch.qos.logback.core.FileAppender[FAE] - File property is set to [logs/myproject/error/messages.log]
12:07:56,762 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,763 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FAF]
12:07:56,763 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,764 |-INFO in ch.qos.logback.core.FileAppender[FAF] - File property is set to [logs/myproject/fatal/messages.log]
12:07:56,764 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
12:07:56,764 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [DEFAULT]
12:07:56,765 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:07:56,765 |-INFO in ch.qos.logback.core.FileAppender[DEFAULT] - File property is set to [logs/default/info/messages.log]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAT] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAD] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAI] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAW] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAE] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FAF] to Logger[my.package]
12:07:56,766 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
12:07:56,766 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [DEFAULT] to Logger[ROOT]
12:07:56,766 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
However, when I deploy the extension to my stand-alone server I'm getting the following log entries in console.log:
12:05:59,695 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [jar:file:/usr/share/neo4j/system/lib/neo4j-server-2.0.1.jar!/logback.xml]
12:05:59,696 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs multiple times on the classpath.
12:05:59,696 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/usr/share/neo4j/system/lib/neo4j-server-2.0.1.jar!/logback.xml]
12:05:59,696 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] occurs at [jar:file:/usr/share/neo4j/plugins/myproject.jar!/logback.xml]
12:05:59,710 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@542ebbbd - URL [jar:file:/usr/share/neo4j/system/lib/neo4j-server-2.0.1.jar!/logback.xml] is not of type file
12:05:59,803 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
12:05:59,806 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
12:05:59,810 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
12:05:59,825 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
12:05:59,861 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to INFO
12:05:59,861 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
12:05:59,861 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
12:05:59,862 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@4827a078 - Registering current configuration as safe fallback point
=> so I think that neither the settings from the logback config from neo4j nor the settings from the logback config from myproject will be registered and the fallback config (conf/logging.properties (?)) will be utilised.
Now my question is: is it possible to integrate an own logback config via an unmanaged extension or do I need to tweak the default logging.properties?
Have you tried to configure your logging in
conf/custom-logback.xml? Neo4j bundles alogback.xmlthat includes this one.