Logback the output log file, which is placed under the directory of the startup process by default
For example, if the program runs directly in Eclipse, it will output to the directory where Eclipse.exe resides, and if run in TOMCAT, it will be exported to the%tomcat_home%/bin directory
<appender name= "FILE"
class= "Ch.qos.logback.core.rolling.RollingFileAppender" >
<rollingpolicy class= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy" >
<filenamepattern>mylog/logfile.%d{ yyyy-mm-dd}.log</filenamepattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%-4relative%d{hh:mm:ss. SSS}-[%thread]%-5level%class-%msg%n</pattern>
</encoder>
</appender>
If the application is deployed under JBOSS and the above configuration file is used, a MyLog folder is created in the%jboss_home%/bin directory
Of course, this is not usually the case, because the log files in the application server's Bin directory is very strange, so you can use absolute path or relative path, the location of the configuration log file
Absolute path:
<appender name= "FILE"
class= "Ch.qos.logback.core.rolling.RollingFileAppender" >
<rollingpolicy class= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy" >
<filenamepattern>/opt/xxx/log/logfile .%d{yyyy-mm-dd}.log</filenamepattern>
<maxHistory>30</maxHistory>
</rollingpolicy >
<encoder>
<pattern>%-4relative%d{hh:mm:ss. SSS}-[%thread]%-5level%class-%msg%n</pattern>
</encoder>
</appender>
Relative path:
<property name= "LogDir" value= ". /.. /youcanfindme "/>
<appender name=" FILE "
class=" Ch.qos.logback.core.rolling.RollingFileAppender " >
<rollingpolicy class= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy" >
< Filenamepattern>${logdir}/logfile.%d{yyyy-mm-dd}.log</filenamepattern>
<maxHistory>30</ maxhistory>
</rollingPolicy>
<encoder>
<pattern>%-4relative%d{hh:mm:ss. SSS}-[%thread]%-5level%class-%msg%n</pattern>
</encoder>
</appender>
The Logback version here is the latest logback-1.0.4, and the old version seems to have a problem configuring the relative path.