window和linux tomcat logback部署catalina.out按日期大小分割
window下logback按日期和大小分割日记1.本项目使用maven工程导入maven 架包dependency>groupId>ch.qos.logbackgroupId>artifactId>logback-classicartifactId>version>1.2.1version>dependency>dependency>groupId>ch.
·
window下logback按日期和大小分割日记
1.本项目使用maven工程导入maven 架包
<dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-access</artifactId> <version>1.2.1</version> </dependency> <dependency> <groupId>org.logback-extensions</groupId> <artifactId>logback-ext-spring</artifactId> <version>0.1.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.21</version> </dependency>2 logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="60 seconds" debug="false"> <property name="rootLevel" value="INFO" /> <property name="appName" value="ahdsm" /> <contextName>${appName}</contextName> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> <charset>UTF-8</charset> </encoder> </appender> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <FileNamePattern>${catalina.home:-.}/logs/${appName}.%d{yyyy-MM-dd}.%i.log</FileNamePattern> <maxFileSize>2GB</maxFileSize> <maxHistory>30</maxHistory> <totalSizeCap>2GB</totalSizeCap> </rollingPolicy> <encoder> <pattern>%msg%n</pattern> <charset>UTF-8</charset> </encoder> </appender> <root level="${rootLevel}"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> </configuration>2.linux下需要安装 cronolog-1.6.2.tar.gz工具来分割日记
1.安装cronolog工具,见附件
(1)解压:tar zxvf cronolog-1.6.2.tar.gz
(2)进入解压后的目录: cd cronolog-1.6.2
(3)执行:./configure
(4)编译:make
(5)安装:make install
(6)设置tomcat
在tomcat/bin/catalina.sh中找到:
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_BASE"/logs/catalina.out 2&1 &
将其改为:
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
|/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.out.%Y-%m-%d >> /dev/null &
更多推荐
已为社区贡献1条内容
所有评论(0)