<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FVelocity%2FVelocity_Log</id>
		<title>Java/Velocity/Velocity Log - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FVelocity%2FVelocity_Log"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Velocity/Velocity_Log&amp;action=history"/>
		<updated>2026-04-19T04:30:35Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Velocity/Velocity_Log&amp;diff=8525&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Velocity/Velocity_Log&amp;diff=8525&amp;oldid=prev"/>
				<updated>2010-06-01T07:07:31Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:07, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Velocity/Velocity_Log&amp;diff=8524&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Velocity/Velocity_Log&amp;diff=8524&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Console Log System ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import org.apache.velocity.runtime.RuntimeServices;&lt;br /&gt;
import org.apache.velocity.runtime.log.LogSystem;&lt;br /&gt;
public class ConsoleLogSystem implements LogSystem {&lt;br /&gt;
  private RuntimeServices rs;&lt;br /&gt;
  private int maxLevel = LogSystem.INFO_ID;&lt;br /&gt;
  private static final String[] LEVEL_NAMES = new String[] { &amp;quot;ERROR&amp;quot;, &amp;quot;WARN&amp;quot;,&lt;br /&gt;
      &amp;quot;INFO&amp;quot;, &amp;quot;DEBUG&amp;quot; };&lt;br /&gt;
  private static final int[] LEVELS = new int[] { LogSystem.ERROR_ID,&lt;br /&gt;
      LogSystem.WARN_ID, LogSystem.INFO_ID, LogSystem.DEBUG_ID };&lt;br /&gt;
  public void init(RuntimeServices rs) throws Exception {&lt;br /&gt;
    System.out.println(&amp;quot;ConsoleLogSystem.init() called&amp;quot;);&lt;br /&gt;
    this.rs = rs;&lt;br /&gt;
    configure();&lt;br /&gt;
  }&lt;br /&gt;
  public void logVelocityMessage(int level, String message) {&lt;br /&gt;
    if (level &amp;gt;= maxLevel) {&lt;br /&gt;
      System.out.println(&amp;quot;[&amp;quot; + getLevelName(level) + &amp;quot;] &amp;quot; + message);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void configure() {&lt;br /&gt;
    String maxLevelName = rs.getString(&amp;quot;console.logsystem.max.level&amp;quot;);&lt;br /&gt;
    int level = getLevelFromString(maxLevelName);&lt;br /&gt;
    if (level &amp;gt; -1) {&lt;br /&gt;
      System.out.println(&amp;quot;Using log level: &amp;quot; + maxLevelName);&lt;br /&gt;
      maxLevel = level;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private int getLevelFromString(String levelName) {&lt;br /&gt;
    for (int x = 0; x &amp;lt; LEVEL_NAMES.length; x++) {&lt;br /&gt;
      if (LEVEL_NAMES[x].equals(levelName)) {&lt;br /&gt;
        return LEVELS[x];&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // should not arrive here, couldn&amp;quot;t find the level&lt;br /&gt;
    return -1;&lt;br /&gt;
  }&lt;br /&gt;
  private String getLevelName(int level) {&lt;br /&gt;
    for (int x = 0; x &amp;lt; LEVELS.length; x++) {&lt;br /&gt;
      if (LEVELS[x] == level) {&lt;br /&gt;
        return LEVEL_NAMES[x];&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return &amp;quot;UNKNOWN&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Custom log for Velocity ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2000-2001,2004 The Apache Software Foundation.&lt;br /&gt;
 * &lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import org.apache.velocity.app.Velocity;&lt;br /&gt;
import org.apache.velocity.VelocityContext;&lt;br /&gt;
import org.apache.velocity.Template;&lt;br /&gt;
import org.apache.velocity.exception.ParseErrorException;&lt;br /&gt;
import org.apache.velocity.exception.ResourceNotFoundException;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
/**&lt;br /&gt;
 * This class is a simple demonstration of how the Velocity Template Engine&lt;br /&gt;
 * can be used in a standalone application.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to use an existing Log4j Category as the Velocity logging target ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2000-2001,2004 The Apache Software Foundation.&lt;br /&gt;
 * &lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import org.apache.log4j.BasicConfigurator;&lt;br /&gt;
import org.apache.log4j.Category;&lt;br /&gt;
import org.apache.velocity.app.VelocityEngine;&lt;br /&gt;
import org.apache.velocity.runtime.RuntimeConstants;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *  Simple example class to show how to use an existing Log4j Categeory&lt;br /&gt;
 *  as the Velocity logging target.&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This is a toy demonstration of how Velocity can use an externally configured logger ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Copyright 2000-2001,2004 The Apache Software Foundation.&lt;br /&gt;
 * &lt;br /&gt;
 * Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 * you may not use this file except in compliance with the License.&lt;br /&gt;
 * You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import org.apache.velocity.app.Velocity;&lt;br /&gt;
import org.apache.velocity.runtime.log.LogSystem;&lt;br /&gt;
import org.apache.velocity.runtime.RuntimeServices;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *  This is a toy demonstration of how Velocity&lt;br /&gt;
 *  can use an externally configured logger.  In &lt;br /&gt;
 *  this example, the class using Velocity&lt;br /&gt;
 *  implements Velocity&amp;quot;s logger interface, and&lt;br /&gt;
 *  all Velocity log messages are funneled back&lt;br /&gt;
 *  through it.&lt;br /&gt;
 *&lt;br /&gt;
 * @author&lt;/div&gt;</summary>
			</entry>

	</feed>