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

[Stash] Create separate log file for plugin

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

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.

I'm OK with an upvote. :)

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.

Community showcase

Speaker Required!

Hey Everyone! Our next AUG on the 26th of November is at the AWS offices in the city!   🙌 I'm looking for a speaker for our event.  This could be an interesting story, use c...

12 views 0 0
View post

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