Jira Plugin & Log4J

I came across this problem lately when I was working on a Jira plugin. A Jira plugin does not rely on a OSGi container or some similar plugin framework. The plugin consists mainly of a jar file that gets deployed with (I mean inside…) the Jira Java EE web application.

Logging is an issue in such an environment: the surrounding application configures the logging API – there is no way to provide log4j configuration fragments.

The best way I found to solve the problem was (again) to use the native logging API to the configuration manually. Since Jira has already setup the logging API, all I needed was to add some categories with some levels, or, if I need to, create my own appenders. That’s all possible with the API exposed by log4j.

So I created a Jira component module inside my plugin that does the configuration magic. Jira uses PicoContainer (lightweight, embedable, configurable, POJO based IOC/DI component runtime) as the runtime for their own and for components provided by plugins. As components get initialized along with the Jira application it is good place to implement the required logging configuration:

Just by adding this component to the atlassian-plugin.xml in my plugin I solved my problems with distributed logging configuration:

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.