Caused by: java.io.FileNotFoundException: velocity.log (No such file or directory)

时间:2021-11-01 16:32:10
Caused by: org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:875)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262)
at org.apache.velocity.runtime.RuntimeInstance.requireInitialization(RuntimeInstance.java:302)
... 26 more
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:220)
at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269)
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871)
... 28 more
Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute :
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.velocity.util.ExceptionUtils.createWithCause(ExceptionUtils.java:67)
at org.apache.velocity.util.ExceptionUtils.createRuntimeException(ExceptionUtils.java:45)
at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:133)
at org.apache.velocity.runtime.log.Log4JLogChute.init(Log4JLogChute.java:85)
at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:157)
... 30 more
Caused by: java.io.FileNotFoundException: velocity.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
at org.apache.log4j.FileAppender.<init>(FileAppender.java:110)
at org.apache.log4j.RollingFileAppender.<init>(RollingFileAppender.java:79)
at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:118)
... 32 more

问题原因是velocity的日志框架导致(velocity是使用自己封装的日志框架记录日志的),velocity在初始化Logger时,如果没有读取到配置文件,则会使用默认的velocity.log做为文件输出路径,源代码里使用了 File file = new File(“velocity.log”) 代码片段,这样创建的文件目录是在启动jvm进程的用户目录下(也就是user.dir属性)。

解决办法: 
1、添加一个velocity.properties日志配置文件 
2、修改velocity的代码,把日志转接到应用里使用的日志框架上来。 
3、解决的方式是直接关闭Velocity日志。 
在调用 Velocity.init(); 之前 
设置: 
Velocity.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, “org.apache.velocity.runtime.log.NullLogChute”);

Caused by: java.io.FileNotFoundException: velocity.log (No such file or directory)的更多相关文章

  1. java&period;io&period;FileNotFoundException&colon; rmi&lowbar;keystore&period;jks &lpar;No such file or directory&rpar;(转)

    Caused by: java.io.FileNotFoundException: rmi_keystore.jks (没有那个文件或目录) 解决方法:修改jmeter.properites: ser ...

  2. velocity模板引擎 -- java&period;io&period;FileNotFoundException&colon; velocity&period;log &lpar;Permission denied&rpar;

    问题原因是velocity的日志框架导致(velocity是使用自己封装的日志框架记录日志的),velocity在初始化Logger时,如果没有读取到配置文件,则会使用默认的velocity.log做 ...

  3. Caused by&colon; java&period;io&period;FileNotFoundException

    1.错误描述 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...

  4. Caused by&colon; java&period;io&period;FileNotFoundException&colon; class path resource &lbrack;spring&sol;springmvc&period;xml&rsqb; cannot be opene

                        Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc. ...

  5. cloudera-scm-server启动时出现Caused by&colon; java&period;io&period;FileNotFoundException&colon; &sol;var&sol;lib&sol;cloudera-scm-server&sol;&period;keystore &lpar;No such file or directory&rpar;问题解决方法(图文详解)

    不多说,直接上干货! 问题详情 查看/var/log/cloudera-scm-server.log的启动日志 问题来源 我在用cloudermanager安装好之后,然后,在对如下. 配置kerbe ...

  6. cxf&lpar;3&period;1&period;1&rpar; 异常Caused by&colon; java&period;io&period;FileNotFoundException&colon; class path resource &lbrack;META-INF&sol;cxf&sol;cxf-extension-soap&period;xml&rsqb;

    Caused by: java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] ...

  7. 报错:Caused by&colon; java&period;io&period;FileNotFoundException&colon; d&colon;&bsol;youTemprepository&bsol;upload&lowbar;77faffc1&lowbar;1580a9240ca&lowbar;&lowbar;8000&lowbar;00000001&period;tmp &lpar;系统找不到指定的路径。&rpar;

    org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-dat ...

  8. Caused by&colon; java&period;io&period;FileNotFoundException&colon; class path resource &lbrack;applicationContext&period;xml&rsqb; cannot be ope

    1.错误描述 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.tes ...

  9. Caused by&colon; java&period;io&period;FileNotFoundException&colon; class path resource

    异常: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.c ...

随机推荐

  1. java 中多线程之间的通讯之等待唤醒机制

    wait notify () nitifyAll () 都使用在同步中,因为要对持有监视器(锁)的线程操作 所以要使用在同步中,因为只有同步才具有锁 为什么这些操作线程的方法要定义object类中呢 ...

  2. js string 转 int Number()

    var numString = '122'; var numberInt = Number(numString); var res = numberInt/2; 结果: res = 61

  3. iOS现有工程 集成 Cordova&sol;Ionic

    首先, 新建 Cordova 项目就不说了, 步骤: http://ionicframework.com/getting-started/ , cordova生成的项目用cdv_project称呼, ...

  4. 轻应用 lapp

    轻应用 LAPP (Light App) 即轻应用是一种无需下载.即搜即用的全功能 App,既有媲美甚至超越native app的用户体验,又具备webapp的可被检索与智能分发的特性,将有效解决优质 ...

  5. 基于libevent&comma; libuv和android Looper不断演进socket编程 - 走向架构师之路 - 博客频道 - CSDN&period;NET

    基于libevent, libuv和android Looper不断演进socket编程 - 走向架构师之路 - 博客频道 - CSDN.NET 基于libevent, libuv和android L ...

  6. &lt&semi;EffectiveJava&gt&semi;读书笔记--01继承的使用注意

    1, 父类的构造器方法中不能调用能够被子类重写的方法. 分析: 当初始化一个子类时, 首先要初始化父类, 即调用父类的构造方法; 如果父类的构造方法中调用了可被重写的其它方法, 那么此时调用的其实是该 ...

  7. 非WifI环境处理

    //1.创建网络状态监测管理者 AFNetworkReachabilityManager *mangerStatus = [AFNetworkReachabilityManager sharedMan ...

  8. 《Thinking In Java》阅读笔记

    <Thinking In Java>阅读笔记 前四章:对象导论. 一切都是对象. 操作符. 控制执行流程 public在一个文件中只能有一个,可以是一个类class或者一个接口interf ...

  9. C语言----管道

    一.管道的概念 管道是一种队列类型的数据结构,它的数据从一端输入,另一端输出.管道最常见的应用是连接两个进程的输入输出,即把一个进程的输出编程另一个进程的输入.shell中存在专门的管道运算符&quo ...

  10. Dispatch Queue 内存结构

    Dispatch 源代码版本是libdispatch-84.5.5  会根据这个结构来分析dispatch_queue 对应的代码实现 参考 GCD源码分析3 -- dispatch_queue篇 ...