All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.velocity.tools.generic.LogTool Maven / Gradle / Ivy

Go to download

Generic tools that can be used in any context. PLEASE NOTE: this is a temporary fork to unblock projects migrating to Jakarta, but I won't continue maintaining it in the future as the Velocity team doesn't understand the value of Jakarta. I strongly suggest you plan a switch to a more modern template engine such as Thymeleaf.

The newest version!
package org.apache.velocity.tools.generic;
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.io.Serializable;
import org.apache.velocity.tools.Scope;
import org.apache.velocity.tools.config.DefaultKey;
import org.apache.velocity.tools.config.ValidScope;

/**
 * 

* This tool is used to log from within templates. *

*

* Of course, the desired log level must have been configured, using the method specific * to the SLF4J implementation you are using. For instance, when using the webapp-slf4j-logger, * you will use the following snippet of code in you /WEB-INF/web.xml file:

*
 * <context-param>
 *   <param-name>webapp-slf4j-logger.level</param-name>
 *   <param-value>debug</param-value>
 * </context-param>
 * 
* *

You can optionnaly specify the logger name in the config (the default is to re-use the engine logger):

*
 * <tools>
 *   <toolbox scope="application">
 *     <tool class="org.apache.velocity.tools.generic.LogTool"/>
 *   </toolbox>
 * </tools>
 * 
* * @author Claude Brisson * @since VelocityTools 3.0 * @version $Id: $ */ @DefaultKey("log") @ValidScope(Scope.APPLICATION) public class LogTool extends SafeConfig implements Serializable { private static final long serialVersionUID = 2081207016220808266L; public void error(String message) { getLog().error(message); } public void warn(String message) { getLog().warn(message); } public void info(String message) { getLog().info(message); } public void debug(String message) { getLog().debug(message); } public void trace(String message) { getLog().trace(message); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy