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

Logging for Stash Plugin in Production Environment?

Jacob Schoen April 28, 2013

How exactly can this be accomplished? Essentially I am trying to debug an issue with a post hook plugin we wrote, that is only affecting one repository.

I know using atlas-run there are some options so that I can see logging, but I have been unsuccesful in recreating the problem locally (See Using your own log4j configuration for your plugin if you would like to know how to do that). Thus logging in a production environment would be most beneficial.

I have tried

private static final Logger logger = LoggerFactory.getLogger("com.atlassian.stash");

and

private static final Logger logger = LoggerFactory.getLogger("atlassian.plugin");

Neither have worked.

Edit: I did find a similar question Debug Logging in Crucible Plugin, but that was pretty much the same info I posted here already.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jacob Schoen April 29, 2013

It appears the correct way to handle this would be to add the below to your class:

private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("atlassian.plugin");

Then update the file `stash-config.properties` located in your Stash Home directory to have the following line:

log4j.logger.attlassian.plugin=DEBUG

You can change `atlassian.plugin` to be anything you want, typically this is the name of your class including the pacakage. You will more than likely restart Stash for these changes to take affect.

jhinch (Atlassian)
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 29, 2013

This is due to the fact that Stash doesn't use log4j but rather its successor logback.

Jacob Schoen April 29, 2013

@Jason Sorry your statement doesn't really seem relevant to me. Maybe I am missing something. I was using the slf4j imports originally, I just included them in the answer to be clearer for others that may have a similar issue. The real problem to me is, when I create a logger for my plugin, it does not log info statements (like the ones you see in the log file from atlassian classes). I was under the assumption that the default log level for everything was INFO (i.e. the root logger was set to info), where as that does not seem to be the case. I also assumed that under anministration when you set it to debug, it would set the root logger to DEBUG, but again it only seems to set certain packages to debug. Logback vs log4j really is not an issue (other than imports) since logback can use a log4j config for set up. The documentation around configuring logging for plugins is not all that clear, and how to log in a production environment for that matter is even less clear. For example a way to set debug logging while the app is running would be great, expecially if we could add this to the settings for plugins.

jhinch (Atlassian)
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 29, 2013

The document you pointed to in the question is for configuring log4j. Since Stash doesn't use log4j (it uses logback) it won't work. Modifying the stash-config.properties or adding a logback.xml file in the home directory (creating one if it doesn't exist) is the correct way. I was merely extending on your answer so other people can understand why using a log4j.properties file doesn't work.

Jacob Schoen April 29, 2013

Thanks for the the clarification that stashes uses logback and log4j, and more details on how to properly configure the logging.

Is there a document that explains this for Stash then? Both from the administration side on how to configure it, and from the plugin developrs side on the reccomendation way of doing logging in our plugin. Basically should developers be using `attlassian.plugin` for the logger name or should we use the more standard full classname including package that is usually used.

The reason I ask is if in my hook I used a logger named `com.company.hook.MyHook` then when a user had a problem I would have to tell them how to configure logging to find out what was happening. Whereas in theory, stash was designed for all plugins to use `atlassian.plugin` then when they turn on debugging, Stash could set the log level for it to debug (In theory as I do not believe it currently does that) along with the other atlassian loggers that are changed to debug.

So I could see arguments for both sides, and it would be nice to have a recommended way to do this from Atlassian.

TAGS
AUG Leaders

Atlassian Community Events