2013-10-18 2 views
12

나는 속도 로그를 사용하지 않도록 노력했습니다, 나는 긍정적 인 결과로 지금까지 찾은 유일한 방법은 설정하는 것입니다 :속도 기록을 해제하는 방법

runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem 

을하지만, velocity.properties 내에서 그 존재 velocity.jar 내부.

웹 응용 프로그램 (tomcat) 컨텍스트에서 속도를 사용하고 있습니다. JAR을 수정하지 않고 속도를 비활성화 할 수있는 방법이 있습니까 (이전 속성을 설정하는 등). velocity 시작에 당신이 어떤을 알 수와

//java configuration 
VelocityEngine ve = new VelocityEngine(); 
ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute"); 
ve.setProperty("runtime.log.logsystem.log4j.logger","velocity"); 

//log4j properties 
log4j.category.velocity=WARN 

는 이럴 INFO 괜찮 :

코드를 사전에

감사를 수정할 수 없습니다가

+0

후 응용 프로그램 로깅 속성을 호출하는 경우
봐, – Keerthivasan

+0

난 그냥 내부의 속도에 대해 아무것도와 log4j.properties가 – luiso1979

답변

2

이것은 당신이 velocity에서 로깅을 원하는 구성 할 수있는 방법입니다 유용한 속도 엔진 구성 세부 사항, 그러나 templating 도중 INFO 수준에서 특별한 아무것도 나오지 않는다.

+0

나는 것을 잊었 으면 미안 코드를 (건드릴 수 없어 자세한 내용은 질문을 편집합니다) – luiso1979

+0

또한 Velocity [documentation] (http://velocity.apache.org/engine/devel/developer-guide.html#Configuring_Logging) – luiso1979

2

당신은 VelocityBuilder 인터페이스의 메소드 VelocityEngine 엔진()를 구현 한 다음 다음과 같이 사용 할 파일을 지정할 수 있습니다

resource.loader = framework 

framework.resource.loader.description = Framework Templates Resource Loader 
framework.resource.loader.class = applica.framework.library.velocity.WEBINFResourceLoader 

webapp.resource.loader.class = org.apache.velocity.tools.view.servlet.WebappLoader 
webapp.resource.loader.path = 
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem 
file.resource.loader.description = Velocity File Resource Loader 
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader 
file.resource.loader.path = 

class.resource.loader.description = Velocity Classpath Resource Loader 
class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader 
12

:

public VelocityEngine engine() { 
       if(engine == null) { 
        engine = new VelocityEngine(); 

        Properties properties = new Properties(); 
        InputStream in = null; 
        try { 
//here is where you specify the filename "/WEB-INF/velocity.properties" 
         in = webApplicationContext.getServletContext().getResourceAsStream("/WEB-INF/velocity.properties"); 
         properties.load(in); 
         engine.init(properties); 
        } catch (IOException e) { 
         e.printStackTrace(); 
         logger.error("Error loading velocity engine properties"); 
         throw new ProgramException("Cannot load velocity engine properties"); 
        } 

        IOUtils.closeQuietly(in); 
       } 

       return engine; 
      } 

을 그리고 당신의 velocity.properties 파일에서 후 일반적으로 : 다음 줄을 내 컴퓨터에 추가하십시오. velocity.properties :

runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogChute 

질문하시기 바랍니다. : 속도 엔진이 어떻게로드되는지에 따라 다릅니다. 맞춤 velocity.properties 파일을 제공 할 수 있습니까?
예를 들어 Solr의 VelocityResponseWriterv.properties (또는 현재 버전에서는 init.properties.file)이라는 속성을 가지고 있습니다. 방법 org.apache.velocity.app.VelocityEngine.init(Properties)이 ... 어딘가에 코드에서