Commit 5815c54d by guanguan1009

增加日志配置

parent 151cb447
......@@ -22,60 +22,16 @@ public class Pdf2Pptx {
public static void main(String[] args) {
//读取指定文件夹下所有文件并转换为图片
List<String> allFilePathName = new ArrayList<>();
FileUtil.getAllFilePathNameRe(Constant.SOURCE_PATH, allFilePathName);
for (String filePathName : allFilePathName) {
File file = new File(filePathName);
if (file.getName().endsWith(".pdf")) {
//判断图片是否存在
List<String> allDirPathName = new ArrayList<>();
FileUtil.getAllDirPathNameRe(Constant.SOURCE_PATH, allDirPathName);
if (!allDirPathName.contains(file.getAbsolutePath().replace(".pdf", "_图片"))) {
logger.info("转换pdf:{} 为图片开始", file.getAbsolutePath());
long begin = System.currentTimeMillis();
Pdf2Png.pdf2Image(file.getAbsolutePath(), file.getParent(), 350);
long end = System.currentTimeMillis();
logger.info("转换pdf:{} 为图片完成,耗时{}ms", file.getAbsolutePath(), end - begin);
} else {
logger.info("文件:{} 已经转换", file.getName());
}
}
}
logger.info("======== pdf转图片已完成,准备生成pptx ========");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//将图片插入PPT
List<String> allDirPathName = new ArrayList<>();
FileUtil.getAllDirPathNameRe(Constant.SOURCE_PATH, allDirPathName);
for (String dirPathName : allDirPathName) {
File dir = new File(dirPathName);
//判断ppt是否存在
if (dir.getName().endsWith("_图片")) {
List<String> allPptPathFileName = new ArrayList<>();
FileUtil.getAllFilePathNameRe(Constant.SOURCE_PATH, allPptPathFileName);
if (!allPptPathFileName.contains(dir.getAbsolutePath().replace("_图片", ".pptx"))) {
List<String> filePathNames = FileUtil.getAllFilePathName(dir.getAbsolutePath());
//转换
logger.info("开始转换图片:{} 为pptx", dir.getName());
long begin = System.currentTimeMillis();
Png2Pptx.createPicturePptx(filePathNames, dir);
long end = System.currentTimeMillis();
logger.info("转换图片:{} 为pptx完成,耗时:{}ms", dir.getName(), end - begin);
} else {
logger.info("文件:{} 已经存在", dir.getName() + ".pptx");
}
}
}
// conver(Constant.SOURCE_PATH);
}
public void converte(String path){
conver(path);
}
private static void conver(String path) {
//读取指定文件夹下所有文件并转换为图片
/*List<String> allFilePathName = new ArrayList<>();
List<String> allFilePathName = new ArrayList<>();
FileUtil.getAllFilePathNameRe(path, allFilePathName);
for (String filePathName : allFilePathName) {
......@@ -124,7 +80,6 @@ public class Pdf2Pptx {
}
}
*/
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds" debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="/home/javaLog" />
<!--<property name="appName" value="${elk.jty.app.name}" />-->
<!--<property name="serverId" value="${elk.jty.app.serverId}" />-->
<!--<property name="logstashHost" value="192.168.242.8" />-->
<!--<property name="logstashPort" value="9601" />-->
<!--<springProperty scope="context" name="appName" source="elk.jty.app.name" />-->
<!-- 该配置将作为存入ES索引名称的一部分,所以不能含有大写字母 -->
<springProperty scope="context" name="appName" source="spring.application.name" />
<property name="outFormat" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" />
<property name="outFormatFile" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%X{sessionId}] [%X{servlet_path}] [%X{username}] [%X{res_status}] [%X{execution_time}] [%thread] %-5level %logger{50} - %msg%n" />
<contextName>${APP_Name}</contextName>
<!--控制台日志, 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度,%msg:日志消息,%n是换行符-->
<pattern>${outFormat}</pattern>
</encoder>
</appender>
<!--文件日志, 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/TestWeb.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/%d{yyyy-MM}/TestWeb.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>${outFormat}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
<!--myibatis log configure-->
<!--<logger name="com.apache.ibatis" level="TRACE"/>-->
<!--<logger name="java.sql.Connection" level="DEBUG"/>-->
<!--<logger name="java.sql.Statement" level="DEBUG"/>-->
<!--<logger name="java.sql.PreparedStatement" level="DEBUG"/>-->
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE"/>
</root>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment