How to configure log of nvelocity?

114 Views Asked by At

NVelocity seems to be creating a nvelocity.log in the root or our website. Apparently it is using log4net, but it is not using our current log4net configuration because our logs are in another folder.

How can we change the location of the nvelocity.log file?

1

There are 1 best solutions below

0
Dzyann On BEST ANSWER

After some research, I found that nvelocity is being initialized using the SimpleLog4NetLogSystem, the existing configuration (this is an old feature on the site) is telling nvelocity to use the NullLogSystem. I think that's why the file is created empty and never modified, SimpleLog4NetLogSystem is used at first but then the NullLogSystem. I think it is some bug on this version.

Anyway I found how to change the configuration file, at least in the version we are using (1.0.3324.33234):

var props = new ExtendedProperties();               
props.AddProperty("runtime.log", "Logs\\nvelocity.log");

Velocity.Init(props);

In later versions "runtime.log" is specified by the NVelocity.Runtime.RuntimeConstants.RUNTIME_LOG constant.

Also the Velocity.Init can receive a configuration file so you don't have to hardcode the name of the log file.