How can I write a user plugin log to a different log file

JFrog Support
2018-11-15 12:04


Separating user-plugin logs with other logs.
Writing the log to a different log file for user plugin, for instance, consider you are writing your user plugin and you want to see the logs of it in a separate file.  


For instance, consider you are writing your user plugin and you have added your log output methods as follows:

def newRepoPathString = id + "/" + itemInfo.getName()
                           log.warn("first element is: " + repoPathElements[0])
                           log.warn("layout.getModule() is: " + layout.getModule())

You can then go to your $ARTIFACTORY_HOME/etc/logback.xml file and add the following two snippets at the bottom of it:

1. A log appender, detailing the separate output file along with other settings:

<appender name="<appenderName>" class="ch.qos.logback.core.rolling.RollingFileAppender">



<pattern>%date ${artifactory.contextId}[%thread] [%-5p] (%-20c{3}:%L) – %m%n</pattern>


<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">




<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">




2. The logger itself with an appender:

<logger name="<pluginName>" additivity="false">

<level value="warn" />

<appender-ref ref="<appenderName>"/>


While the logger name attribute should be accompanied with your plugin's matching name, the appender-ref will direct the logger to a configured appender.

Final note, the logging level can be set to 4 different levels that we usually use, info / warn / debug / trace. In the example above, warn was used.