Bob thanks, it solved it. I also noticed changing the click mode to profile got 
rid of the velocity messages I was seeing (error messages would probably show 
up though). Does this set up (velocity.properties in WEB-INF) override the 
velocity.properties in the click.jar or supplement it with updated values? I'm 
wondering if I will need to extract the one in the jar and modify it.

Muzaffer

> -----Original Message-----
> From: Bob Schellink [mailto:[email protected]]
> Sent: Thursday, December 11, 2008 4:08 PM
> To: [email protected]
> Subject: Re: Logging in 1.4.2
> 
> You should be able to specify a custom Velocity logger through
> velocity.properties.
> 
> Copy a velocity.properties file to your WEB-INF folder with the
> following content:
> 
>    runtime.log.logsystem.class = package.of.logger.JdkClickLogger
> 
> That should override the logger Click setup by default.
> 
> Does that work for you?
> 
> kind regards
> 
> bob
> 
> 
> Ozakca, Muzaffer wrote:
> > Hi, messages from the click are being diverted to Log4j but I'm getting
> these messages in the console:
> >
> > [Velocity] [info ] WebappLoader : initialization starting.
> > [Velocity] [info ] WebappLoader : initialization complete.
> > [Velocity] [info ] Velocimacro : autoload on : VM system will
> automatically reload global library macros
> >
> > I think another ClickLogger is being initialized for Velocity. I looked at
> the code but it seems a bit more complicated. Any ideas how to override that
> also?
> >
> > Muzaffer
> >
> >> -----Original Message-----
> >> From: Ozakca, Muzaffer [mailto:[email protected]]
> >> Sent: Thursday, December 11, 2008 11:30 AM
> >> To: [email protected]
> >> Subject: RE: Logging in 1.4.2
> >>
> >> Thanks Bob, this is of great help!
> >>
> >> Muzaffer
> >>
> >>> -----Original Message-----
> >>> From: Bob Schellink [mailto:[email protected]]
> >>> Sent: Thursday, December 11, 2008 10:32 AM
> >>> To: [email protected]
> >>> Subject: Re: Logging in 1.4.2
> >>>
> >>> Hi Muzaffer,
> >>>
> >>>
> >>> Ozakca, Muzaffer wrote:
> >>>> I’m still using 1.4.2 at the moment and wondering if there is a simple
> >>>> way to change logging that is currently going to console. I guess,
> >>>> setting the mode to “production” would remove most all logging messages
> >>>> but I’m curious if there is a way to send log messages to a file. Would
> >>>> I need to override ClickLogger?
> >>>
> >>> Yes you'll need to extend it and create a custom ClickServlet which
> >>> overrides #createClickLogger to return the new logger.
> >>>
> >>> Below is an example of how you could adapt to Java Logging (or Log4J).
> >>> Please make a note that if you upgrade to 1.5 you'll need to remove
> >>> this custom logger and switch to either the new JdkLogService or
> >>> Log4JLogService.
> >>>
> >>>
> >>>
> >>> MyClickServlet.java
> >>>
> >>> public class MyClickServlet extends ClickServlet {
> >>>
> >>>    protected ClickLogger createClickLogger() {
> >>>      return new JdkClickLogger();
> >>>    }
> >>> }
> >>>
> >>>
> >>> JdkClickLogger.java
> >>>
> >>> public class JdkClickLogger extends ClickLogger {
> >>>
> >>>      private Logger logger =
> >>> Logger.getLogger(JdkClickLogger.class.getName());
> >>>
> >>>      private Level level = Level.INFO;
> >>>
> >>>      /** The level names. */
> >>>      private static final String[] LEVELS =
> >>>      { " [trace] ", " [debug] ", " [info ] ", " [warn ] ", " [error] "
> };
> >>>
> >>>      public JdkClickLogger() {
> >>>      }
> >>>
> >>>      public void log(int levelInt, String message, Throwable error) {
> >>>
> >>>          Level newLevel = Level.INFO;
> >>>
> >>>          switch(levelInt) {
> >>>              case 0:
> >>>                  newLevel = Level.FINE;
> >>>                  break;
> >>>              case 1:
> >>>                  newLevel = Level.INFO;
> >>>                  break;
> >>>              case 2:
> >>>                  newLevel = Level.INFO;
> >>>                  break;
> >>>              case 3:
> >>>                  newLevel = Level.WARNING;
> >>>              case 4:
> >>>                  newLevel = Level.SEVERE;
> >>>          }
> >>>          initLogLevels(newLevel);
> >>>          logger.log(level, message, error);
> >>>      }
> >>>
> >>>      // Tricky bit with Java Logger. Need to init the new Log level
> >>>      private void initLogLevels(Level newLevel) {
> >>>          if(level.equals(newLevel)) {
> >>>              return;
> >>>          }
> >>>          level = newLevel;
> >>>
> >>>          Logger rootLogger = Logger.getLogger("");
> >>>          rootLogger.setLevel(level);
> >>>
> >>>          Handler[] handlers = rootLogger.getHandlers( );
> >>>
> >>>          for (int i = 0; i < handlers.length; i++) {
> >>>              handlers[i].setLevel(level);
> >>>              //handlers[i].setLevel(Level.OFF);
> >>>          }
> >>>      }
> >>> }

Reply via email to