java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[?:1.8.0_341]
at java.io.File.createNewFile(File.java:1023) ~[?:1.8.0_341]
at com.xxl.job.core.log.XxlJobFileAppender.appendLog(XxlJobFileAppender.java:100) [classes/:?]
at com.xxl.job.core.context.XxlJobHelper.logDetail(XxlJobHelper.java:164) [classes/:?]
at com.xxl.job.core.context.XxlJobHelper.log(XxlJobHelper.java:118) [classes/:?]
at com.xxl.job.core.thread.JobThread.run(JobThread.java:176) [classes/:?]
2022-11-22 22:08:55.510 ERROR 57512 --- [rCallbackThread] c.x.j.c.l.XxlJobFileAppender : No such file or directory
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[?:1.8.0_341]
at java.io.File.createNewFile(File.java:1023) ~[?:1.8.0_341]
at com.xxl.job.core.log.XxlJobFileAppender.appendLog(XxlJobFileAppender.java:100) [classes/:?]
at com.xxl.job.core.context.XxlJobHelper.logDetail(XxlJobHelper.java:164) [classes/:?]
at com.xxl.job.core.context.XxlJobHelper.log(XxlJobHelper.java:118) [classes/:?]
at com.xxl.job.core.thread.TriggerCallbackThread.callbackLog(TriggerCallbackThread.java:197) [classes/:?]
at com.xxl.job.core.thread.TriggerCallbackThread.doCallback(TriggerCallbackThread.java:170) [classes/:?]
at com.xxl.job.core.thread.TriggerCallbackThread.access$200(TriggerCallbackThread.java:26) [classes/:?]
at com.xxl.job.core.thread.TriggerCallbackThread$1.run(TriggerCallbackThread.java:76) [classes/:?]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_341]
public static void appendLog(String logFileName, String appendLog) {
// log file
if (logFileName==null || logFileName.trim().length()==0) {
return;
}
File logFile = new File(logFileName);
if (!logFile.exists()) {
try {
//报错行!!!!!!!!!!!!注意!!!!!!! XxlJobFileAppender.java:100
logFile.createNewFile();
} catch (IOException e) {
logger.error(e.getMessage(), e);
return;
}
}
问题:每次XXL-JOB运行时候报错log日志文件就会报错。原因是文件不存在,直接修改下面类的logBasePath属性就可以,修改成自己的路径,如果是linux直接修改在root目录下
public class XxlJobFileAppender {
private static Logger logger = LoggerFactory.getLogger(XxlJobFileAppender.class);
/**
* log base path
*
* strut like:
* ---/
* ---/gluesource/
* ---/gluesource/10_1514171108000.js
* ---/gluesource/10_1514171108000.js
* ---/2017-12-25/
* ---/2017-12-25/639.log
* ---/2017-12-25/821.log
*
*/
//private static String logBasePath = "/data/applogs/xxl-job/jobhandler";
private static String logBasePath = "/Users/liuzhenyu/Desktop/log"; //上面是未更改的
private static String glueSrcPath = logBasePath.concat("/gluesource");
public static void initLogPath(String logPath){
// init
if (logPath!=null && logPath.trim().length()>0) {
logBasePath = logPath;
}
// mk base dir
File logPathDir = new File(logBasePath);
if (!logPathDir.exists()) {
logPathDir.mkdirs();
}
logBasePath = logPathDir.getPath();
// mk glue dir
File glueBaseDir = new File(logPathDir, "gluesource");
if (!glueBaseDir.exists()) {
glueBaseDir.mkdirs();
}
glueSrcPath = glueBaseDir.getPath();
}
原文地址:https://blog.csdn.net/L1511768722/article/details/127991132
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_43508.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。