Which log4j file used by the atlassian-sdk?

Logan G Hawkes
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.
February 15, 2013

I'm trying to customize the log4j.properties file that's used when I start Jira via atlas-run but I'm not having much luck. Every time I restart atlas-run whatever file is in use gets overwritten with a default file.
I've tried specifying a log4j.properties file at invocation with "atlas-run --log4j C:\atlastutorial\userstorydefectreport\jira-report-plugin\src\log4j.properties" but that doesn't seem to work either. The atlassian-jira.log just reverts to its old format.

I've gone so far as to search my drive to find every file with the name log4j.properties and modify each one's layout.ConversionPattern parameter so I could track down which file was in effect, but that didn't work either. When I run atlas-run the default file gets rooted out and dropped into place.

When Jira starts I see this in the console output: -Djava.util.logging.config.file=C:\atlastutorial\userstorydefectreport\jira-report-plugin\target\container\tomcat6x\cargo-jira-home/conf/logging.properties

I checked that file, and it's a very short log4j.properties file with very basic parameters. I have found that it's in effect until startup is complete. During startup I see this message:

[INFO] jira started successfully in 165s at http://AUTO-SYS-1-226:2990/jira
[INFO] Type Ctrl-D to shutdown gracefully
[INFO] Type Ctrl-C to exit

At that point a new layout.ConversionPattern seems to kick in, which is far more verbose:

[INFO] [talledLocalContainer] 2013-02-15 19:21:42,551 QuartzWorker-1 
INFO ServiceRunner Backup Service [jira.bc.dataimport.DefaultExportService] Data export completed in 219ms. Wrote 959 entities to export in memory.

I've also tried creating a custom log4j.properties file and passing it as part of the maven compilation via my pom.xml as per this post. Again, no luck. That file also gets ignored.

<plugin>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
      <source>1.6</source>
      <target>1.6</target>
      <log4jProperties>src/log4j.properties</log4jProperties>
   </configuration>
</plugin>

This has become maddening, as I have to reconfigure all my logging every time I restart Jira and I'm stuck with a gigantic layout.ConversionPattern that fills up the first 100+ characters of every log file entry with useless information.

Can someone provide some guidance? I'm using SDK v 4.1.1 on Windows 2008 with Apache Maven 2.1.0 and Eclipse Helios. My goal is to write a custom plugin for Jira 5.1.8.

Thanks.

2 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
Jozef Kotlár
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.
February 15, 2013

The used log4j.properties file is located in expanded JIRA application, so it is in directory target\jira\webapp\WEB-INF\classes. That is not overwritten after first atlas-run (after atlas-clean), so your changes will be persisted so the easiest, but clumsy is to modify it manually after first atlas-run. Other solutions would be:

  • provide modified jira.war file (installed in your local repository or mirror)
  • modify given file using maven-patch-plugin (just idea - not implemented)
Logan G Hawkes
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.
February 16, 2013

If I understand you then the way to make sure my custom log4j.properties will be used by Jira and will not be overwritten between restarts of atlas-run is:

  1. Run atlas-clean to get started
  2. There will be a stock log4j.properties file at target\jira\webapp\WEB-INF\classes\log4j.properties that I can customize.
  3. Run atlas-run.
  4. The custom file at target\jira\webapp\WEB-INF\classes\log4j.properties will not be overwritten.
  5. If I stop and restart atlas-run the custom target\jira\webapp\WEB-INF\classes\log4j.properties will not be overwritten. My changes will persist.

I am pretty sure that I've already tried this, although it's hard to be sure because I've made so many changes to the various log4j.properties files that I've found littering my dev environment. Is there any pitfall that I should be aware of?

Jozef Kotlár
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.
February 17, 2013

No, the order should be

  1. Run atlas-clean and then atlas-run to get started
  2. Stop JIRA.
  3. There will be a stock log4j.properties file at target\jira\webapp\WEB-INF\classes\log4j.properties that I can customize.
  4. Run atlas-run again.
  5. The custom file at target\jira\webapp\WEB-INF\classes\log4j.properties will not be overwritten.
  6. If I stop and restart atlas-run the custom target\jira\webapp\WEB-INF\classes\log4j.properties will not be overwritten. My changes will persist.
1 vote
Mirko Skramusky
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.
March 13, 2013

Hi!

For the sake of completeness: You can change the typical log output to any file by setting the output parameter in your pom.xml:

<plugin>
	<groupId>com.atlassian.maven.plugins</groupId>
	<artifactId>maven-confluence-plugin</artifactId>
	<configuration>
		<output>${build.directory}\atlassian-confluence.log</output>
		[...]
	</configuration>
	[...]
</plugin>

Jozef Kotlár
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.
March 13, 2013

Great, this is not exactly answer for this question as it changes only location of output, but it hints me to look into maven-jira-plugin:run documentation and heck, yes - there is parameter log4jProperties and it really replaces bundled log4j.propertieswithout need of tweaks mentioned above:

<build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-jira-plugin</artifactId>
        <configuration>
          <productDataPath>src/test/resources/jira-home.zip</productDataPath>
          <log4jProperties>src/test/resources/log4j.properties</log4jProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>

Mirko Skramusky
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.
March 13, 2013

Yes, there're some not so extremly good documented features. ;)

The log4jProperties you mentioned is helpful and instead of "output" documented in the link posted by Byron Orpheus above. So sorry, I skiped this hint. :)

TAGS
AUG Leaders

Atlassian Community Events