[ 
https://issues.apache.org/jira/browse/VELOCITY-371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henning Schmiedehausen closed VELOCITY-371.
-------------------------------------------


> Compatibility with log4j 1.3 alpha
> ----------------------------------
>
>                 Key: VELOCITY-371
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-371
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.4
>         Environment: Operating System: All
> Platform: All
>            Reporter: Curtis Morehead
>         Assigned To: Curtis Morehead
>            Priority: Blocker
>         Attachments: diff.txt
>
>
> The 1.3 alpha release of log4j changed the location and usage of the 
> RollingFileAppender class. These changes are not currently backwards 
> compatible 
> and, as such, the SimpleLog4JLogSystem implementation must be changed 
> accordingly.
> Steps to reproduce:
> With log4j 1.3 alpha in the classpath, any code calling the init method of a 
> VelocityEngine instance will fail with the following error:
> java.lang.NoSuchFieldError: DEBUG
>       at org.apache.velocity.runtime.log.SimpleLog4JLogSystem.internalInit
> (SimpleLog4JLogSystem.java:112)
>       at org.apache.velocity.runtime.log.SimpleLog4JLogSystem.init
> (SimpleLog4JLogSystem.java:82)
>       at org.apache.velocity.runtime.log.LogManager.createLogSystem
> (LogManager.java:127)
>       at org.apache.velocity.runtime.RuntimeInstance.initializeLogger
> (RuntimeInstance.java:553)
>       at org.apache.velocity.runtime.RuntimeInstance.init
> (RuntimeInstance.java:226)
>       at org.apache.velocity.runtime.RuntimeInstance.init
> (RuntimeInstance.java:461)
>       at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:106)
>       ….
> Other information:
> This issue was raised and discussed on the developer mail list at the 
> following 
> thread <a href="http://mail-archives.eu.apache.org/mod_mbox/jakarta-velocity-
> dev/200503.mbox/[EMAIL PROTECTED]
> 3e">http://mail-archives.eu.apache.org/mod_mbox/jakarta-velocity-
> dev/200503.mbox/[EMAIL PROTECTED]
> 3e</a>. 
> Resolution:
> The above thread references a posting made by one of the log4j developers who 
> indicated that the development of compatibility libraries had been suggested 
> for incorporation. If these are added, then the problem goes away until those 
> classes have been sufficiently deprecated and removed.
> The alternate solution is modification of the code base to reflect the 
> changes. 
> This, however, will cause incompatibility problems with previous versions of 
> the log4j library. The following represents the code changes required for 
> compatibility. The changes below also replace the deprecated Category class 
> usage with Logger as indicated in the message from the aforementioned log4j 
> developer.
> diff –w SimpleLog4JLogSystem.old SimpleLog4JLogSystem.java
> 21,22c21,22
> < import org.apache.log4j.Category;
> < import org.apache.log4j.RollingFileAppender;
> ---
> > import org.apache.log4j.Logger;
> > import org.apache.log4j.rolling.RollingFileAppender;
> 24c24,26
> < import org.apache.log4j.Priority;
> ---
> > import org.apache.log4j.rolling.SizeBasedTriggeringPolicy;
> > import org.apache.log4j.rolling.FixedWindowRollingPolicy;
> > import org.apache.log4j.Level;
> 44c46
> <     protected Category logger = null;
> ---
> >     protected Logger logger = null;
> 63c65
> <             logger = Category.getInstance( categoryname );
> ---
> >             logger = Logger.getLogger( categoryname );
> 105c107,108
> <         logger = Category.getInstance(this.getClass().getName());
> ---
> >         logger = Logger.getLogger(this.getClass().getName());
> > 
> 112,114c115
> <         logger.setPriority(Priority.DEBUG);
> < 
> <         RollingFileAppender appender = new RollingFileAppender( new 
> PatternLayout( "%d - %m%n"), logfile, true);
> ---
> >         logger.setLevel(Level.DEBUG);
> 116c117,129
> <         appender.setMaxBackupIndex( 1 );
> ---
> >         RollingFileAppender appender = new RollingFileAppender();
> >         appender.setFile(logfile);
> >         appender.setLayout(new PatternLayout( "%d - %m%n"));
> >         appender.setAppend(true);
> >         
> >         SizeBasedTriggeringPolicy triggerPolicy = new 
> SizeBasedTriggeringPolicy();
> >         triggerPolicy.setMaxFileSize(100000);
> >         appender.setTriggeringPolicy(triggerPolicy);
> >         
> >         FixedWindowRollingPolicy rollingPolicy = new 
> > FixedWindowRollingPolicy
> ();
> >         rollingPolicy.setActiveFileName(logfile);
> >         rollingPolicy.setMaxIndex(1);
> >         appender.setRollingPolicy(rollingPolicy);
> 118c131
> <         appender.setMaximumFileSize( 100000 );
> ---
> >         appender.activateOptions();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to