It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I control logging in an Atlassian Stash Plugin?

I know atlassian stash uses logback, not log4j. Using the plugin SDK with jira or other atlassian products, you can do this in your POM:


What is the equivalent for stash? How can I control logger levels for my debug instance without having to manually copy files around? How can I bundle logging inside my plugin? (e.g. write a special log to a special file appender?) There are no examples I can find in the atlassian docs.

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted

I now have a working example of configuring logback in a plugin which utilizes a logback.xml on your classpath. See:

For a code example of how to configure loggers. For an example logback.xml, see:



Thanks again to Charles O'Farrell who guided me to correct solution, here I will outline if someone else wants to do that:

  • ${PLUGIN_FOLDER}/pom.xml - added following dependency
    • <dependency>
      <!-- <version>1.0.11</version> version from stash-parent/pom.xml -->
  • ${PLUGIN_FOLDER}/src/main/resources/atlassian-plugin.xml - add following component
    • <component key="stashbotLoggerFactory" class="com.chegg.plugin.prercv.YOURLoggerFactory"/>
  • ${PLUGIN_FOLDER}/src/main/resources/logback.xml - Created pretty similar to yours containing only one appender with similar settings (creating ROOT on package)
  • ${PLUGIN_FOLDER}/src/main/java/ - Pretty much similar to what StashbotLoggerFactory is.

You will find the logs under ${PLUGIN_FOLDER}/target/container/tomcat7x/cargo-stash-home/YOUR.log

Anyone else try this?  I tried to follow along but every time I upgrade my plugin I get an additional line in the log. I mean if I install it it logs one line to the file if I then upgrade, it logs two identical lines to the file, upgrade again, three etc. 

Hi Carl,

There are two options for modifying the logback config:

- Add a logback.xml file to the <stash home> directory, this will be merged with Stash's logback config, however this is not portable; the file will need to added once for every Stash server.

- Configure logback in your plugin Java code. You can use the ApplicationPropertiesService to get the home directory to ensure you are logging in the correct place.

Hope that helps,


Thanks, this is helpful, but I am still having problems. I don't quite understand what my logging commands should look like, or how I should configure the logging system. I tried to do something like what I found here:

but I still am not seeing log messages. Do you maybe have a code example? What should it look like when my code gets a logger? How do I tell a particular logger to output to the atlassian-stash.log (or console when I run atlas-debug)? Should I use the same logger all across my plugin, or can I have a separate logger for each class? Should I add a dependency on logback to my pom.xml and use it directly? The link above tries to avoid that using reflection and it is a royal pain...

Hi Carl,

I'm curious about exactly what you're trying to do? If you're just trying to set the levels of a logger then you can easily specify the levels in our file, or at runtime using REST:

What are you hoping to use custom appenders for? If you want to define your own customer appenders, as Thomas says you can put an extra logback.xml in the home directory:

&lt;appender name="myappender"&gt;
&lt;!-- I'm assuming you want to output a specific package --&gt;
&lt;logger name="" level="DEBUG"&gt;
    &lt;appender-ref ref="myappender" /&gt;




My goal was to have the plugin log by default, without having to touch stash's configuration at all. I wanted it to be zero-touch, install-the-plugin-and-it-just-works. See my accepted answer for how I ended up doing it.


Despite Thomas' very helpful answer, I am still having problems figuring out how to configure logback. A working example plugin that uses logback to do logging would be great... failing that, maybe some code samples of what I need to do. I've googled and tried to find logback code examples but that code doesn't seem to be working for me...

Carl Myers -

I have trying to create a separate log for my plugin, I looked at your code and replicated these steps, let me know if I missed anything:

  • ${PLUGIN_FOLDER}/pom.xml - added one line to load log4j.prop
    • <log4jProperties>${basedir}/</log4jProperties>
  • ${PLUGIN_FOLDER}/ - added the same file as yours except updating the last line with my className in it
  • ${PLUGIN_FOLDER}/src/main/resources/logback.xml - Created pretty similar to yours containing only one appender with my className in it

Did I miss anything ?

The plugin can be executed but I dont see any log file getting generated through this setup.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Confluence Cloud

Bring information from GitHub into Confluence

I’ve got a couple of questions for you. Do you write technical documentation? What about technical documentation that references code and files from GitHub? In this article you will learn how to in...

32 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you