Not to mention the code: There are two java files in total. The first is the example, the second is the configuration file loading class, And LogbackTest. java/** To change this template, choose Tools | Templates * and open the template in the editor. */package logbacktest; import ch. qos. logback. core. joran. spi. joranException; import java. io. IOException; import org. slf4j. loggerFactory;/***** @ author Administrator */public class LogbackTest {/***** @ param args the command line arguments */publi C static void main (String [] args) throws IOException, JoranException {LogBackConfigLoader. load ("logback-log.xml"); org. slf4j. logger logger = LoggerFactory. getLogger ("snail Il"); logger. debug ("Hello") ;}} LogBackConfigLoader. java/** To change this template, choose Tools | Templates * and open the template in the editor. */package logbacktest; import java. io. file; import java. io. IOException; import Org. slf4j. logger; import org. slf4j. loggerFactory; import ch. qos. logback. classic. loggerContext; import ch. qos. logback. classic. joran. joranaggregator; import ch. qos. logback. core. joran. spi. joranException; import ch. qos. logback. core. util. statusPrinter;/*** Simple Utility class for loading an external config file for logback * @ author daniel */public class LogBackConfigLoader {public static void Load (String externalConfigFileLocation) throws IOException, JoranException {LoggerContext lc = (LoggerContext) LoggerFactory. getILoggerFactory (); File externalConfigFile = new File (externalConfigFileLocation); if (! ExternalConfigFile. exists () {throw new IOException ("Logback External Config File Parameter does not reference a file that exists");} else {if (! ExternalConfigFile. isFile () {throw new IOException ("Logback External Config File Parameter exists, but does not reference a file");} else {if (! ExternalConfigFile. canRead () {throw new IOException ("Logback External Config File exists and is a file, but cannot be read. ");} else {JoranConfigurator aggregator = new JoranConfigurator (); aggregator. setContext (lc); lc. reset (); aggregator. doConfigure (externalConfigFileLocation); StatusPrinter. printInCaseOfErrorsOrWarnings (lc) ;}}} attaches a simple logback-log.xml <? Xml version = "1.0" encoding = "UTF-8"?> <Configuration> <appender name = "STDOUT" class = "ch. qos. logback. core. ConsoleAppender"> <! -- Encoder is configured as PatternLayoutEncoder by default --> <encoder> <pattern> [%-5 level] % d {yyyy-MM-dd HH: mm: ss }%msg % n </pattern> </encoder> </appender> www.2cto.com <appender name = "debug" class = "ch. qos. logback. core. fileAppender "> <File> log/debug. log </File> <Append> true </Append> <encoder> <pattern> [%-5 level] % d {yyyy-MM-dd HH: mm: ss }%msg % n </pattern> </encoder> <filter class = "ch. qos. logback. classic. filter. thresholdFilter "> <level> TRACE </level> </filter> </appender> <logger name =" snil "level =" TRACE "additi.pdf =" false "> <appender- ref = "debug"/> </logger> </configuration>