How to segregate Artifactory warning/error logs in a different file?

Disha Meswania
2020-08-27 11:03

Subject

How to segregate my Artifactory warnings/errors into a different log file and not have everything appended in the artifactory.log file.
 

Affected Versions

Artifactory 6.x
 

Resolution

In Artifactory v6.x, this can be done by making the below changes in 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>