To enable debugging of your Bitbucket plugin using Logback:
- Create the directory
src/test/resources/bitbucket-home
- Create a file
src/test/resources/bitbucket-home/logback.xml
[1] and addlogger
elements as desired, eg I have:
<included>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.format}</pattern>
</encoder>
</appender>
<!--When starting up Elasticsearch in-process (for dev):
We need to set the logging level of org.elasticsearch.bootstrap to ERROR because otherwise
it will log a misleading warning (with a stacktrace) about JNA being unavailable.-->
<logger name="org.elasticsearch.bootstrap" level="ERROR"/>
<logger name="com.declarativesystems" level="DEBUG"/>
<root>
<appender-ref ref="console"/>
</root>
</included>
-
atlas-clean && atlas-run
as normal - you will now be able to see the logs from your plugin on the console.
Log4J
I’m using Bitbucket 5.16 which uses Logback. I couldn’t get log4j working at all:
Log4j 1.2 in pom.xml
causes my whole plugin to fail:
Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.declarativesystems.bitbucket.credentialscanner [126]: Unable to resolve 126.0: missing requirement [126.0] osgi.wiring.package; (osgi.wiring.package=com.ibm.uvm.tools)
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
... 22 common frames omitted
Using the OSGi version
<dependency>
<groupId>org.apache.logging.log4j.osgi</groupId>
<artifactId>log4j-core-osgi-reduced</artifactId>
<scope>provided</scope>
<version>2.0-rc1</version>
</dependency>
Doesn’t break anything but doesn’t give any debug output either
HTH
[1] This is a homedir override, as discussed in Atlassian Maven Plugin Suite - Issues - Ecosystem Jira … I would never have found this workaround without this ticket!