首先打开logback的配置文件,在configuration标签中加入xsd的配置
<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback
https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
</configuration>
然后将鼠标光标放到https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd 的红色区域上,按alt+enter, 点击fetch external resource,会自动下载xsd文件。
如果无法下载,则在resource下创建logback.xsd文件
<?xml version="1.0" encoding="UTF-8"?>
<!--
logback.xml schema,
https://github.com/enricopulatzo/logback-XSD
https://github.com/nkatsar/logback-XSD
-->
<xsd:schema targetNamespace="http://ch.qos.logback/xml/ns/logback"
xmlns="http://ch.qos.logback/xml/ns/logback"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.1">
<xsd:element name="configuration" type="Configuration"/>
<xsd:element name="included" type="Configuration"/>
<xsd:complexType name="Configuration">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="shutdownHook" minOccurs="0" maxOccurs="1" type="ShutdownHook"/>
<xsd:element name="statusListener" minOccurs="0" maxOccurs="unbounded" type="StatusListener"/>
<xsd:element name="contextListener" minOccurs="0" maxOccurs="unbounded" type="ContextListener"/>
<xsd:element name="jmxConfigurator" minOccurs="0" maxOccurs="1" type="JmxConfigurator"/>
<xsd:element name="conversionRule" minOccurs="0" maxOccurs="unbounded" type="ConversionRule"/>
<xsd:element name="include" minOccurs="0" maxOccurs="unbounded" type="Include"/>
<xsd:element name="contextName" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="define" minOccurs="0" maxOccurs="unbounded" type="Define"/>
<xsd:element name="timestamp" minOccurs="0" maxOccurs="1" type="Timestamp"/>
<xsd:element name="if" minOccurs="0" maxOccurs="unbounded" type="If"/>
<xsd:element name="property" minOccurs="0" maxOccurs="unbounded" type="Property"/>
<xsd:element name="appender" minOccurs="0" maxOccurs="unbounded" type="Appender"/>
<xsd:element name="logger" minOccurs="0" maxOccurs="unbounded" type="Logger"/>
<xsd:element name="root" minOccurs="0" maxOccurs="1" type="Root"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="debug" type="xsd:boolean" use="optional"/>
<xsd:attribute name="scan" type="xsd:boolean" use="optional" default="false"/>
<xsd:attribute name="scanPeriod" type="xsd:string" use="optional" default="1 minute"/>
<xsd:attribute name="packagingData" type="xsd:boolean" use="optional" default="false"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="ShutdownHook">
<xsd:attribute name="class" type="xsd:string" use="optional"
default="ch.qos.logback.core.hook.DelayingShutdownHook"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="ConversionRule">
<xsd:attribute name="conversionWord" type="xsd:string"/>
<xsd:attribute name="converterClass" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="StatusListener">
<xsd:attribute name="class" type="xsd:string" use="optional"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="ContextListener">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="resetJUL" type="xsd:boolean"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="class" type="xsd:string"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Include">
<xsd:attribute name="file" use="optional" type="xsd:string"/>
<xsd:attribute name="resource" use="optional" type="xsd:string"/>
<xsd:attribute name="url" use="optional" type="xsd:string"/>
<xsd:attribute name="optional" use="optional" type="xsd:boolean"/>
</xsd:complexType>
<xsd:complexType name="Define">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Timestamp">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string" use="optional"/>
<xsd:attribute name="datePattern" type="xsd:string" use="optional"/>
<xsd:attribute name="timeReference" type="xsd:string" use="optional"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="RollingPolicy">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="fileNamePattern" minOccurs="1" maxOccurs="1" type="xsd:string"/>
<xsd:element name="maxHistory" minOccurs="0" maxOccurs="1" type="xsd:int"/>
<xsd:element name="minIndex" minOccurs="0" maxOccurs="1" type="xsd:int"/>
<xsd:element name="maxIndex" minOccurs="0" maxOccurs="1" type="xsd:int"/>
<xsd:element name="timeBasedFileNamingAndTriggeringPolicy" minOccurs="0" maxOccurs="1" type="TriggeringPolicy"/>
<xsd:element name="cleanHistoryOnStart" minOccurs="0" maxOccurs="1" type="xsd:boolean"/>
<xsd:element name="maxFileSize" minOccurs="0" maxOccurs="1" type="FileSize"/>
<xsd:element name="totalSizeCap" minOccurs="0" maxOccurs="1" type="FileSize"/>
</xsd:choice>
<xsd:attribute name="class" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:simpleType name="FileSize">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[1-9][0-9]*(KB|MB|GB)?"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="TriggeringPolicy">
<xsd:sequence>
<xsd:element name="maxFileSize" minOccurs="0" maxOccurs="1" type="FileSize"/>
</xsd:sequence>
<xsd:attribute name="class" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:complexType name="If">
<xsd:choice maxOccurs="unbounded">
<xsd:element type="Configuration" name="then"/>
<xsd:element type="Configuration" name="else"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="condition" type="xsd:string"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Property">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="scope" type="xsd:string" use="optional"/>
<xsd:attribute name="name" type="xsd:string" use="optional"/>
<xsd:attribute name="value" type="xsd:string" use="optional"/>
<xsd:attribute name="file" type="xsd:string" use="optional"/>
<xsd:attribute name="resource" type="xsd:string" use="optional"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Appender">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="target" minOccurs="0" maxOccurs="1" type="Target"/>
<xsd:element name="file" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="withJansi" minOccurs="0" maxOccurs="1" type="xsd:boolean"/>
<xsd:element name="encoder" minOccurs="0" maxOccurs="1" type="Encoder"/>
<xsd:element name="filter" minOccurs="0" maxOccurs="1" type="Filter"/>
<xsd:element name="append" minOccurs="0" maxOccurs="1" type="xsd:boolean"/>
<xsd:element name="prudent" minOccurs="0" maxOccurs="1" type="xsd:boolean"/>
<xsd:element name="layout" minOccurs="0" maxOccurs="1" type="Layout"/>
<xsd:element name="rollingPolicy" minOccurs="0" maxOccurs="1" type="RollingPolicy"/>
<xsd:element name="connectionSource" minOccurs="0" maxOccurs="1" type="ConnectionSource"/>
<xsd:element name="triggeringPolicy" minOccurs="0" maxOccurs="1" type="TriggeringPolicy"/>
<xsd:element name="appender-ref" minOccurs="0" maxOccurs="1" type="AppenderRef"/>
<xsd:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="class" type="xsd:string" use="required"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:simpleType name="Target">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="System.out"/>
<xsd:enumeration value="System.err"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Filter">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="level" minOccurs="0" maxOccurs="unbounded" type="LoggerLevel"/>
<xsd:element name="onMatch" minOccurs="0" maxOccurs="unbounded" type="MatchValue"/>
<xsd:element name="onMismatch" minOccurs="0" maxOccurs="unbounded" type="MatchValue"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="class" type="xsd:string" use="optional"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:simpleType name="MatchValue">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="ACCEPT"/>
<xsd:enumeration value="DENY"/>
<xsd:enumeration value="NEUTRAL"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Layout">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="pattern" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="class" type="xsd:string" use="optional"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Logger">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="appender-ref" minOccurs="0" maxOccurs="unbounded" type="AppenderRef"/>
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="level" type="LoggerLevel" use="optional"/>
<xsd:attribute name="additivity" type="xsd:boolean" use="optional" default="true"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="Encoder">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="charset" type="xsd:string" minOccurs="0" maxOccurs="1"/>
<xsd:element name="immediateFlush" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="layout" minOccurs="0" maxOccurs="1" type="Layout"/>
<xsd:element name="outputPatternAsHeader" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
<xsd:element name="pattern" type="xsd:string" minOccurs="0" maxOccurs="1"/>
</xsd:choice>
<xsd:attribute name="class" type="xsd:string" use="optional"
default="ch.qos.logback.classic.encoder.PatternLayoutEncoder"
/>
</xsd:complexType>
<xsd:complexType name="Root">
<xsd:sequence>
<xsd:element name="appender-ref" minOccurs="0" maxOccurs="unbounded" type="AppenderRef"/>
</xsd:sequence>
<xsd:attribute name="level" use="required" type="LoggerLevel"/>
<xsd:anyAttribute/>
</xsd:complexType>
<xsd:complexType name="AppenderRef">
<xsd:attribute name="ref" type="xsd:string"/>
</xsd:complexType>
<xsd:simpleType name="LoggerLevel">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="OFF"/>
<xsd:enumeration value="off"/>
<xsd:enumeration value="ALL"/>
<xsd:enumeration value="all"/>
<xsd:enumeration value="INHERITED"/>
<xsd:enumeration value="inherited"/>
<xsd:enumeration value="NULL"/>
<xsd:enumeration value="null"/>
<xsd:enumeration value="ERROR"/>
<xsd:enumeration value="error"/>
<xsd:enumeration value="WARN"/>
<xsd:enumeration value="warn"/>
<xsd:enumeration value="INFO"/>
<xsd:enumeration value="info"/>
<xsd:enumeration value="DEBUG"/>
<xsd:enumeration value="debug"/>
<xsd:enumeration value="TRACE"/>
<xsd:enumeration value="trace"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="($\{.+:-)?[Oo][Ff]{2}\}?"/>
<xsd:pattern value="($\{.+:-)?[Aa][Ll]{2}\}?"/>
<xsd:pattern value="($\{.+:-)?[Ii][Nn][Hh][Ee][Rr][Ii][Tt][Ee][Dd]\}?"/>
<xsd:pattern value="($\{.+:-)?[Nn][Uu][Ll]{2}\}?"/>
<xsd:pattern value="($\{.+:-)?[Ee][Rr]{2}[Oo][Rr]\}?"/>
<xsd:pattern value="($\{.+:-)?[Ww][Aa][Rr][Nn]\}?"/>
<xsd:pattern value="($\{.+:-)?[Ii][Nn][Ff][Oo]\}?"/>
<xsd:pattern value="($\{.+:-)?[Dd][Ee][Bb][Uu][Gg]\}?"/>
<xsd:pattern value="($\{.+:-)?[Tt][Rr][Aa][Cc][Ee]\}?"/>
<xsd:pattern value="\$\{.+\}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
<xsd:complexType name="JmxConfigurator"/>
<xsd:complexType name="ConnectionSource">
<xsd:sequence>
<xsd:element name="driverClass" type="xsd:string"/>
<xsd:element name="url" type="xsd:string"/>
<xsd:element name="user" type="xsd:string"/>
<xsd:element name="password" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="class" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>