top.doudou.core.properties.CustomLogProperties Maven / Gradle / Ivy
package top.doudou.core.properties;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import top.doudou.core.util.time.DateTimeUtil;
import java.io.File;
/**
* @author 傻男人<[email protected]>
* @Date: 2020/8/25 14:06
* @Version: 1.0
* @Description: 请求日志的配置
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "custom.log")
public class CustomLogProperties {
@Value("${spring.application.name:logs}")
private String applicationName;
/**
* 错误日志名字
*/
private String errorLogName = "."+File.separator+applicationName+File.separator+"customLog"+File.separator + "error.log";
/**
* 超时日志名字
*/
private String overtimeLogName = "."+File.separator+applicationName+File.separator+"customLog"+File.separator + "overtime.log";
/**
* 超时时间
*/
private Long timeOut = 500L;
/**
* 接口请求日志名字
*/
private String requestLogName = "."+File.separator+applicationName+File.separator+"customLog"+File.separator + "request.log";
/**
* 是否将日志信息记录到日志文件
*/
private boolean logRequest = false;
/**
* sql日志名字
*/
private String sqlLogName = "."+File.separator+"customLog"+File.separator + "sql_log.log";
/**
* 基础日志文件位置
*/
private String basePath = System.getProperty("user.home");
/**
* 日志文件的名字
*/
private String logName = "output.log";
/**
* 日志文件中是否添加项目名的文件夹
*/
private boolean addProjectNameToPath = true;
/**
* 打印sql
*/
private boolean printSql = true;
/**
* 是否将sql写入到文件
*/
private boolean writeSqlToFile = false;
/**
* 打印sql的结果集
*/
private boolean printSqlResult = false;
public String getFilePath(String fileName){
return basePath +File.separator+ DateTimeUtil.getThisDateTime()+"_"+fileName;
}
public String getDefaultLogFile(){
if(addProjectNameToPath){
return basePath +File.separator+ applicationName +File.separator+logName;
}
return basePath +File.separator+logName;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy