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

[Stash] Create separate log file for plugin

Zeeshan Maqbool January 29, 2014

I have seen lot of questions and forums around this but none of them provides a satisfactory answer. I would like to create a separate log file for my plugin which has nothing to do with atlassian-stash.log, where I have complete control over root-logging level (info, debug, warn).

If someone can provide an example code, I can offer a one-way ticket to heaven.

2 answers

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
Zeeshan Maqbool January 30, 2014

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>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <!-- <version>1.0.11</version> version from stash-parent/pom.xml -->
      <scope>provided</scope>
      </dependency>
  • ${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/YOURLoggerFactory.java - Pretty much similar to what StashbotLoggerFactory is.

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

Not sure if I can offer the ticket exclusively to you Charles since Carl's changes made my day, nevertheless a touching thanks since it made my life really easy.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2014

I'm OK with an upvote. :)

1 vote
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2014

Hi Zeeshan,

Is it possible to look at your code that you tried for the following?

https://answers.atlassian.com/questions/188880/how-do-i-control-logging-in-an-atlassian-stash-plugin?page=1

I don't think I've seen anyone else get that working except for Carl. You need to use his StashbotLoggerFactory instead of raw SLF4J loggers. I've just tried it locally and it works fine.

Cheers,

Charles

FYI You don't need any of the log4j stuff, we only use logback.

TAGS
AUG Leaders

Atlassian Community Events