Hi Jeffery, sorry, I only now realize, that I have to resolve the applicationroot in xml. A system property would resolve things by itself, but we have to configure it application speicifc (could be done by configuring webapproot with Spring).
Bit if we just want to allow it happen in the same way as for the
log4j.properties file (using ${applicationroot}, we may just replace it in
code before providing input to the log4j domconfigurator.
If we do not want to replace the original, we should copy it e.g.
(log4j-gen.xml). Another option would be to activate watching, replace the
original, which I do not really like to do.
BTW: loggingRoot seems to be removed altogether, which should be reflected
in javadoc/code comments in Turbine.
Best regards, Georg
Von: Jeffery Painter <[email protected]>
An: [email protected]
Datum: 31.10.2018 17:27
Betreff: Re: svn commit: r1845337 - in /turbine/core/trunk: ./
conf/ conf/test/ src/assembly/ src/changes/ src/java/org/apache/turbine/
src/java/org/apache/turbine/modules/screens/
src/test-cactus/testapp/WEB-INF/conf/ src/test/org/apache/turbine/test/
Hi Georg,
I tried to change the archetype to use the log4j.xml but I was having
some trouble getting it working... if you have time to take a look at
it, that would be great.
I fixed some of the versioning info, but I left the log4j.properties as
it was (it seems to still be working as is with your latest commits). I
also updated the changes file. Thanks for adding the notes from my
changes in turbine/core :-)
I will try to remember to stay on top of that in the future.
Thanks!
Jeff
On 10/31/18 11:07 AM, [email protected] wrote:
> Author: gk
> Date: Wed Oct 31 15:07:41 2018
> New Revision: 1845337
>
> URL: http://svn.apache.org/viewvc?rev=1845337&view=rev
> Log:
> - Updating to Turbine Parent 5
> - fix cobertura single report
> - fix docLint for javadoc 3.x
> - fix CVE, exclude in pom
> - use log4j.xml
>
>
> Added:
> turbine/core/trunk/conf/log4j.xml (with props)
> turbine/core/trunk/conf/test/log4j.xml (with props)
> Modified:
> turbine/core/trunk/conf/test/CompleteTurbineResources.properties
> turbine/core/trunk/conf/test/TemplateService.properties
> turbine/core/trunk/conf/test/TestFulcrumComponents.properties
>
turbine/core/trunk/conf/test/TurbineNonPersistentSchedulerServiceTest.properties
> turbine/core/trunk/conf/test/usersettings.properties
> turbine/core/trunk/pom.xml
> turbine/core/trunk/src/assembly/binaries.xml
> turbine/core/trunk/src/changes/changes.xml
> turbine/core/trunk/src/java/org/apache/turbine/TurbineConstants.java
>
turbine/core/trunk/src/java/org/apache/turbine/modules/screens/PlainJSONScreen.java
>
turbine/core/trunk/src/test-cactus/testapp/WEB-INF/conf/TurbineComplete.properties
> turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java
>
> Added: turbine/core/trunk/conf/log4j.xml
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/log4j.xml?rev=1845337&view=auto
>
==============================================================================
> --- turbine/core/trunk/conf/log4j.xml (added)
> +++ turbine/core/trunk/conf/log4j.xml Wed Oct 31 15:07:41 2018
> @@ -0,0 +1,81 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> + 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.
> +-->
> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
> + <appender name="avalon" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="file" value="${applicationRoot}/logs/avalon.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <appender name="scheduler" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="file"
value="${applicationRoot}/logs/scheduler.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <appender name="torque" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="file" value="${applicationRoot}/logs/torque.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <appender name="turbine" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="file"
value="${applicationRoot}/logs/turbine.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <appender name="velocity" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="file"
value="${applicationRoot}/logs/velocity.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <logger name="avalon" additivity="false">
> + <level value="INFO"/>
> + <appender-ref ref="avalon"/>
> + </logger>
> + <logger name="org.apache.torque" additivity="false">
> + <level value="INFO"/>
> + <appender-ref ref="torque"/>
> + </logger>
> + <logger name="org.apache.turbine" additivity="false">
> + <level value="INFO"/>
> + <appender-ref ref="turbine"/>
> + </logger>
> + <logger name="scheduler" additivity="false">
> + <level value="INFO"/>
> + <appender-ref ref="scheduler"/>
> + </logger>
> + <logger name="velocity" additivity="false">
> + <level value="INFO"/>
> + <appender-ref ref="velocity"/>
> + </logger>
> + <root>
> + <level value="INFO"/>
> + <appender-ref ref="turbine"/>
> + </root>
> +</log4j:configuration>
> \ No newline at end of file
>
> Propchange: turbine/core/trunk/conf/log4j.xml
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Modified:
turbine/core/trunk/conf/test/CompleteTurbineResources.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/CompleteTurbineResources.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/conf/test/CompleteTurbineResources.properties
(original)
> +++ turbine/core/trunk/conf/test/CompleteTurbineResources.properties Wed
Oct 31 15:07:41 2018
> @@ -23,7 +23,7 @@ pipeline.default.descriptor = /conf/turb
> #
> # -------------------------------------------------------------------
>
> -log4j.file = Log4j.properties
> +log4j.file = log4j.xml
>
> # -------------------------------------------------------------------
> #
>
> Modified: turbine/core/trunk/conf/test/TemplateService.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/TemplateService.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/conf/test/TemplateService.properties (original)
> +++ turbine/core/trunk/conf/test/TemplateService.properties Wed Oct 31
15:07:41 2018
> @@ -15,7 +15,7 @@
> # specific language governing permissions and limitations
> # under the License.
>
> -log4j.file = Log4j.properties
> +log4j.file = log4j.xml
> #log4j.file = none
> # or resolve relatively e.g.
> #log4j.file = ../../conf/Log4j.properties
>
> Modified: turbine/core/trunk/conf/test/TestFulcrumComponents.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/TestFulcrumComponents.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/conf/test/TestFulcrumComponents.properties
(original)
> +++ turbine/core/trunk/conf/test/TestFulcrumComponents.properties Wed
Oct 31 15:07:41 2018
> @@ -21,7 +21,7 @@
> #
> # -------------------------------------------------------------------
>
> -log4j.file = Log4j.properties
> +log4j.file = log4j.xml
> # context path: cft. javax.servlet.ServletContext.getResource(String)
> pipeline.default.descriptor = conf/turbine-classic-pipeline.xml
>
>
> Modified:
turbine/core/trunk/conf/test/TurbineNonPersistentSchedulerServiceTest.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/TurbineNonPersistentSchedulerServiceTest.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> ---
turbine/core/trunk/conf/test/TurbineNonPersistentSchedulerServiceTest.properties
(original)
> +++
turbine/core/trunk/conf/test/TurbineNonPersistentSchedulerServiceTest.properties
Wed Oct 31 15:07:41 2018
> @@ -21,7 +21,7 @@
> #
> # -------------------------------------------------------------------
>
> -log4j.file = Log4j.properties
> +log4j.file = log4j.xml.properties
>
> # resource relative to context
> pipeline.default.descriptor = /conf/turbine-classic-pipeline.xml
>
> Added: turbine/core/trunk/conf/test/log4j.xml
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/log4j.xml?rev=1845337&view=auto
>
==============================================================================
> --- turbine/core/trunk/conf/test/log4j.xml (added)
> +++ turbine/core/trunk/conf/test/log4j.xml Wed Oct 31 15:07:41 2018
> @@ -0,0 +1,37 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> + 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.
> +-->
> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> +<log4j:configuration debug="false" xmlns:log4j="
http://jakarta.apache.org/log4j/">
> + <appender name="logfile" class="org.apache.log4j.FileAppender">
> + <param name="append" value="false"/>
> + <param name="File" value="target/turbine.log"/>
> + <layout class="org.apache.log4j.PatternLayout">
> + <param name="conversionPattern" value="%d [%t] %-5p %c -
%m%n"/>
> + </layout>
> + </appender>
> + <logger name="org.apache.turbine" additivity="false">
> + <level value="DEBUG"/>
> + <appender-ref ref="logfile"/>
> + </logger>
> + <root>
> + <level value="ERROR"/>
> + <appender-ref ref="logfile"/>
> + </root>
> +</log4j:configuration>
> \ No newline at end of file
>
> Propchange: turbine/core/trunk/conf/test/log4j.xml
>
------------------------------------------------------------------------------
> svn:eol-style = native
>
> Modified: turbine/core/trunk/conf/test/usersettings.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/conf/test/usersettings.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/conf/test/usersettings.properties (original)
> +++ turbine/core/trunk/conf/test/usersettings.properties Wed Oct 31
15:07:41 2018
> @@ -1,4 +1,4 @@
> -log4j.file = Log4j.properties
> +log4j.file = log4j.xml
> # or resolve relatively
> #log4j.file = ../../conf/Log4j.properties
> module.cache=false
>
> Modified: turbine/core/trunk/pom.xml
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/pom.xml?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/pom.xml (original)
> +++ turbine/core/trunk/pom.xml Wed Oct 31 15:07:41 2018
> @@ -823,6 +823,17 @@
> <aggregate>false</aggregate>
> </configuration>
> </plugin>
> + <plugin><!-- since 2.7 running the old report requires to
register it explicitely, otherwise the build may fail -->
> + <groupId>org.codehaus.mojo</groupId>
> + <artifactId>cobertura-maven-plugin</artifactId>
> + <reportSets>
> + <reportSet>
> + <reports>
> + <report>cobertura</report>
> + </reports>
> + </reportSet>
> + </reportSets>
> + </plugin>
> </plugins>
> </reporting>
>
> @@ -944,8 +955,17 @@
> <groupId>avalon-logkit</groupId>
> <artifactId>avalon-logkit</artifactId>
> </exclusion>
> + <exclusion> <!-- exclude this to exclude beanutils v1.8.0 ->
CVE-2014-0114 -->
> + <groupId>commons-configuration</groupId>
> + <artifactId>commons-configuration</artifactId>
> + </exclusion>
> </exclusions>
> </dependency>
> + <dependency> <!-- include more modern version just for
torque-runtime v4.0 -->
> + <groupId>commons-configuration</groupId>
> + <artifactId>commons-configuration</artifactId>
> + <version>1.10</version>
> + </dependency>
> <!-- using snapshot, until released -->
> <dependency>
> <groupId>org.apache.fulcrum</groupId>
> @@ -1098,8 +1118,8 @@
> <configuration>
> <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
> <descriptors>
> - <descriptor>src/assembly/binaries.xml</descriptor>
> - <descriptor>src/assembly/source.xml</descriptor>
> + <descriptor>./src/assembly/binaries.xml</descriptor>
> + <descriptor>./src/assembly/source.xml</descriptor>
> </descriptors>
> <tarLongFileFormat>gnu</tarLongFileFormat>
> </configuration>
> @@ -1110,14 +1130,13 @@
> </build>
> <properties>
> <dependency.check.skip>false</dependency.check.skip>
> + <doclint>none</doclint><!-- since javadoc v.3 this is the
reuqired instead of -Xdoclint:none, remove if turbine parent is correct
again using profile java8 -->
> </properties>
> </profile>
> </profiles>
>
> <properties>
> - <maven.compiler.source>1.8</maven.compiler.source>
> - <maven.compiler.target>1.8</maven.compiler.target>
> -
> + <!-- maven.compiler setting in turbine parent -->
> <!-- TODO: Change for release -->
> <turbine.site.path>turbine/turbine-5.0</turbine.site.path>
> <fulcrum.intake>2.0.0-SNAPSHOT</fulcrum.intake>
>
> Modified: turbine/core/trunk/src/assembly/binaries.xml
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/assembly/binaries.xml?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/src/assembly/binaries.xml (original)
> +++ turbine/core/trunk/src/assembly/binaries.xml Wed Oct 31 15:07:41
2018
> @@ -71,6 +71,7 @@
> <include>roleConfiguration.xml</include>
> <include>turbine-classic-pipeline.xml</include>
> <include>Log4j.properties</include>
> + <include>log4j.xml</include>
> <include>TurbineResources.properties</include>
> </includes>
> </fileSet>
>
> Modified: turbine/core/trunk/src/changes/changes.xml
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/changes/changes.xml?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/src/changes/changes.xml (original)
> +++ turbine/core/trunk/src/changes/changes.xml Wed Oct 31 15:07:41 2018
> @@ -25,6 +25,9 @@
>
> <body>
> <release version="5.0" date="in Subversion">
> + <action type="update" dev="jp">
> + Update from lang to commons lang3
> + </action>
> <action type="add" dev="tv">
> Add ServiceBroker.getApplicationRoot() to allow services to get
their root directory
> </action>
>
> Modified:
turbine/core/trunk/src/java/org/apache/turbine/TurbineConstants.java
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/TurbineConstants.java?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> --- turbine/core/trunk/src/java/org/apache/turbine/TurbineConstants.java
(original)
> +++ turbine/core/trunk/src/java/org/apache/turbine/TurbineConstants.java
Wed Oct 31 15:07:41 2018
> @@ -51,7 +51,7 @@ public interface TurbineConstants
> String LOG4J_CONFIG_FILE = "log4j.file";
>
> /** The default value for the Log4J File */
> - String LOG4J_CONFIG_FILE_DEFAULT =
"/WEB-INF/conf/Log4j.properties";
> + String LOG4J_CONFIG_FILE_DEFAULT =
"/WEB-INF/conf/log4j.xml";
>
> /** This is the default log file to be used for logging
*/
> String DEFAULT_LOGGER = "turbine";
>
> Modified:
turbine/core/trunk/src/java/org/apache/turbine/modules/screens/PlainJSONScreen.java
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/modules/screens/PlainJSONScreen.java?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> ---
turbine/core/trunk/src/java/org/apache/turbine/modules/screens/PlainJSONScreen.java
(original)
> +++
turbine/core/trunk/src/java/org/apache/turbine/modules/screens/PlainJSONScreen.java
Wed Oct 31 15:07:41 2018
> @@ -22,8 +22,6 @@ package org.apache.turbine.modules.scree
> import java.io.OutputStreamWriter;
> import java.io.PrintWriter;
>
> -import javax.servlet.http.HttpServletRequest;
> -
> import org.apache.turbine.pipeline.PipelineData;
> import org.apache.turbine.util.RunData;
> import org.slf4j.Logger;
> @@ -101,14 +99,12 @@ public class PlainJSONScreen extends Raw
> protected void doOutput(PipelineData pipelineData) throws Exception
> {
> RunData data = getRunData(pipelineData);
> -
> - HttpServletRequest request = data.getRequest();
> // read in json!
> String charset = "UTF-8"; //request.getCharacterEncoding();
>
> String json_res =data.getMessage();
>
> - log.debug( "json_res output:" +json_res );
> + log.debug( "json_res output: {}", json_res );
> PrintWriter out = new PrintWriter(
> new
OutputStreamWriter(data.getResponse().getOutputStream(),charset));
> out.print(json_res.toString());
>
> Modified:
turbine/core/trunk/src/test-cactus/testapp/WEB-INF/conf/TurbineComplete.properties
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/test-cactus/testapp/WEB-INF/conf/TurbineComplete.properties?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> ---
turbine/core/trunk/src/test-cactus/testapp/WEB-INF/conf/TurbineComplete.properties
(original)
> +++
turbine/core/trunk/src/test-cactus/testapp/WEB-INF/conf/TurbineComplete.properties
Wed Oct 31 15:07:41 2018
> @@ -31,7 +31,7 @@
> #
> # -------------------------------------------------------------------
>
> -log4j.file = /WEB-INF/conf/Log4j.properties
> +log4j.file = /WEB-INF/conf/log4j.xml
>
> # -------------------------------------------------------------------
> #
>
> Modified:
turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java
> URL:
http://svn.apache.org/viewvc/turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java?rev=1845337&r1=1845336&r2=1845337&view=diff
>
==============================================================================
> ---
turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java
(original)
> +++
turbine/core/trunk/src/test/org/apache/turbine/test/BaseTestCase.java Wed
Oct 31 15:07:41 2018
> @@ -41,8 +41,10 @@ import javax.servlet.ServletConfig;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
> +import javax.xml.parsers.FactoryConfigurationError;
>
> import org.apache.log4j.PropertyConfigurator;
> +import org.apache.log4j.xml.DOMConfigurator;
> import org.apache.turbine.TurbineConstants;
> import org.apache.turbine.pipeline.PipelineData;
> import org.apache.turbine.services.TurbineServices;
> @@ -63,25 +65,42 @@ import org.mockito.stubbing.Answer;
> */
> public abstract class BaseTestCase
> {
> - static File log4jFile = new File("conf/test/Log4j.properties");
> + static File log4jFile = new File("conf/test/log4j.xml");
>
> @BeforeClass
> public static void baseInit()
> throws Exception
> {
>
> - Properties p = new Properties();
> - try
> + if (log4jFile.getName().endsWith(".xml"))
> {
> - p.load(new FileInputStream(log4jFile));
> - p.setProperty(TurbineConstants.APPLICATION_ROOT_KEY, new
File(".").getAbsolutePath());
> - PropertyConfigurator.configure(p);
> -
> + // load XML type configuration
> + // NOTE: Only system property expansion available
> + try
> + {
> + DOMConfigurator.configure(log4jFile.getAbsolutePath());
> + }
> + catch (FactoryConfigurationError e)
> + {
> + System.err.println("Could not configure Log4J from
configuration file "
> + + log4jFile + ": ");
> + e.printStackTrace();
> + }
> }
> - catch (FileNotFoundException fnf)
> - {
> - System.err.println("Could not open Log4J configuration file
"
> - + log4jFile);
> + else {
> + Properties p = new Properties();
> + try
> + {
> + p.load(new FileInputStream(log4jFile));
> + p.setProperty(TurbineConstants.APPLICATION_ROOT_KEY,
new File(".").getAbsolutePath());
> + PropertyConfigurator.configure(p);
> +
> + }
> + catch (FileNotFoundException fnf)
> + {
> + System.err.println("Could not open Log4J configuration
file "
> + + log4jFile);
> + }
> }
> }
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
smime.p7s
Description: S/MIME Cryptographic Signature
