loggers log4j

Velocity problem

Question

Velocity parameter is no longer working, which could lead to 

java.io.FileNotFoundException: velocity.log (Permission denied)

Answer

It should be possible to reconfigure the velocity config.

  1. You would have to define a new logger, in log4j.xml (\webapps\ROOT\WEB-INF\etc\config) Maybe also a new appender is needed.
  2. You have to set this logger on a System property: "runtime.log.logsystem.log4j.logger"

E.g. Creation of a new logger like:

        <Logger name="velocity">
            <AppenderRef ref="Console" />
        </Logger> 

The logger, logs only on console (as I said before a new appender could be defined which use a log file).

And on startup you have to set for Windows:

set JAVA_OPTS=%JAVA_OPTS% -Druntime.log.logsystem.log4j.logger=velocity
 
For Linux/Mac:
export JAVA_OPTS=$JAVA_OPTS  -Druntime.log.logsystem.log4j.logger=velocity

 

Another solution is to override the velocity config itself. You can put a velocity.properties in the classs path for instance in \digital-factory-config\jahia

I suggest changing the "runtime.log" property in this velocity.properties to an existing location where the user who start jahia has the permission to create a log file (for instance, it could be the default log directory) like:

 runtime.log = /opt/...tomcat/logs/velocity.log

And you have to specify as System parameter the location of the new velocity property file (to keep sure that this one is used), for instance in setEnv.sh:

 CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.script.velocity.properties=/opt/....../jahia/digital-factory-config/jahia/velocity.properties"

For both paths, you have to use your install directory.