ARTIFACTORY: How to Segregate Artifactory Warnings/Errors into a Different Log File

Disha Meswania
2020-12-03 10:16

Subject

 

Affected Versions

Relevant Versions: This information pertains to Artifactory versions 6.x only.

 

Resolution

To place your Artifactory warnings/errors into a log file that’s segregated from the artifactory.log file, execute the following changes to the <ARTIFACTORY_HOME>/etc/logback.xml file:

Changes in appender section<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${artifactory.home}/logs/artifactory.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${artifactory.home}/logs/artifactory.%i.log</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>25MB</MaxFileSize>
</triggeringPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.jfrog.common.logging.logback.layout.BackTracePatternLayout">
<pattern>%date [%thread] [%-5p] \(%-20c{3}:%L\) - %m%n</pattern>
</layout>
</encoder>
</appender>

<appender name="Analysis" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${artifactory.home}/logs/analysis.log</File>
<encoder>
<pattern>%date ${artifactory.contextId}[%thread] [%-5p] \(%-20c{3}:%L\) - %m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${artifactory.home}/logs/npm.%i.log</FileNamePattern>
<maxIndex>13</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>

Changes in Logger section
 

<root>
<level value="ALL"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="Analysis"/>
<appender-ref ref="FILE"/>
</root>