Logging to atlassian-confluence.log with log4j from plug-in running Confluence 7.0.1 from the SDK

I’m a Confluence server plug-in developer and am trying to the log4j system supposedly built into Confluence server to output some diagnostics to the atlassian-confluence.log file.

I’ve got everything setup as far as including the log4j loggers in my plug-in Java sources:

// For logging
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Creating a logger for my class:

private static final Logger log = LoggerFactory.getLogger(VSAdmin.class);

and using calling it:

log.error("\n*********************VSAdmin doGet");

I’ve added my packages by name to the logging package list in the Confluence Admin interface, set the logging level to ALL for the package, both in standard and diagnostic modes, restarted Confluence many times, but there simply is no atlassian-confluence.log file to be found.

Again, this is running Confluence 7.0.1 using the SDK atlas-run, so the log files are found in target\confluence\home\logs under the build directory, but while there are other log files there:

atlassian-confluence-profiler.log
atlassian-diagnostics.log
atlassian-synchrony.log
instrumentation.log

There is no atlassian-confluence.log at all anywhere on the system (Windows 10 64-bit) and none of these files contain any standard class log4j logging.

Going out of my mind here just trying to get some log info out.

I can send log strings to the console, but console output isn’t available from our QA server, which is a standard Confluence Server 7.0.1 install.

Are there other files I need to modify on my SDK instance to get logging to happen?

None of the information on the Atlassian Developer docs have been of any use, done everything they suggest, but there is no atlassian-confluence.log file to be found anywhere.

1 Like

Bit late to the party here, but this is a long-standing problem with building Confluence plugins using the Atlassian SDK (see https://community.atlassian.com/t5/Answers-Developer-Questions/Where-are-the-Log-files-for-plugins-when-using-the-SDK/qaq-p/563066, https://community.atlassian.com/t5/Confluence-questions/Where-is-the-atlassian-confluence-log-file-when-running/qaq-p/1183361, and similar posts). It seems like it ought to be fixable with some log4j config, but I too have yet to find a really satisfying answer. Usually I just read whatever’s in the console.

I have also had trouble with getting plugin loglines emitted by org.slf4j.Logger/LoggerFactory to show up in the server logs. I can, however, get com.atlassian.extras.common.log.Logger to work.

It’s frustrating because Atlassian recommends the slf4j logger: https://developer.atlassian.com/server/confluence/logging-guidelines/ and it looks like com.atlassian.extras.common.log.Logger is just using slf4j under the covers. However, logging w/ slf4j from a plugin to atlassian-confluence.log just doesn’t happen in my experience.

I not talking about my local dev server that has the logging redirected to the console. I’m talking about a real staging/prod server with the plugin deployed to it. The loglines from the plugin do NOT appear in atlassian-confluence.log even if I hard-code the logging level to ERROR. The Confluence admin tool for logging levels has no effect at all on the plugin logging (when I’m using slf4j Logger).

Maybe I’m doing something wrong but I could swear I tried everything and then just said heck with it, went back to com.atlassian.extras.common.log.Logger, and the loglines showed up fine. Super frustrating.

I need a logger that a customer can enable using the Confluence admin tools for logging: https://confluence.atlassian.com/doc/configuring-logging-181535215.html

I’m not going to ask a customer to stop their server, edit a log4j.properties file, and restart their server. I’m going to ask a customer to enter a plugin package name in the Confluence logging admin tool and then use the admin tool for exporting a support zip containing loglines that I need.

If anyone knows that the slf4j works fine w.r.t. logging from a plugin to atlassian-confluence.log and is manageable by a user (setting levels) via the Confluence logging admin tool then please let me know. I could not get it to work.


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

public class Foo {
private static final Logger LOGGER = LoggerFactory.getLogger(Foo.class);

Thanks.

I’m going to guess that Confluence’s “Logging and Profiling” tool is buggy.

I can enter a class (or package) into the tool at, say, DEBUG level and it works. Sometimes. Sometimes it does not.

I am careful to always click the tiny “Save” button at the bottom of the page so I know that isn’t the problem.

Sometimes it works, sometimes it doesn’t.

Hello , Hi

When using atlas-run the default for the app is to log to console, that is quite ok in most cases, however in the land of builds/infra you generally want to log to a file which you can then extract as artifact.

to achieve that, you need to update your plugin pom file as follow

<plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <containerId>${containerId}</containerId>
                    <jvmArgs>${jvm.args}</jvmArgs>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <!-- log ouput -->
                    <output>${project.build.directory}/confluence/home/logs/atlassian-confluence.log</output>

The best way to get your classes contributing to the log is to use slf4j as follow

// this is fake java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
private static final Logger log = LoggerFactory.getLogger(MyClass.class);
...
log.info();
log.error();
log.debug();

Now, to get your plugin echo things to the log file automatically, I can think of few ways but I still don’t know how I feel about them; and it is generally a best practice to let the customer control their logging and profiling.

That said, for sake of development you can use <log4jProperties/> tag in your plugin configuration to provide your custom logging during development , see https://developer.atlassian.com/server/framework/atlassian-sdk/amps-build-configuration-reference/#log4jproperties for details

I hope this helps.