Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I add logging to my stash plugin

Jonny Heavey December 19, 2014

Hello,

I'm trying to write my first Stash plugin (implementing a PreRecieveHook). I have a bug in the plugin, and would like to add some logging (which would be nice to have anyway). However, I cannot see how to do this. I've seen several questions/answers on more complex logging requirements (separate files for plugin etc), but I just need to output to the console / main logfile. Could anyone help with this?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Michael Heemskerk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 19, 2014

You can use slf4j loggers like this:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class MyComponent {
    private static final Logger log = LoggerFactory.getLogger(MyComponent.class);
 
    public void myMethod() {
        ...
        log.info("Log a message here");
        ...
    }
}

By default INFO, WARN and ERROR log message should be enabled. If you want to see DEBUG and TRACE as well, you can customize the logging configuration through a custom logback.xml in your STASH_HOME directory or by adding stash-config.properties as described here: https://confluence.atlassian.com/display/STASH/Stash+debug+logging

TAGS
AUG Leaders

Atlassian Community Events