You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by cz...@apache.org on 2004/05/04 13:14:28 UTC
cvs commit: avalon-excalibur/logger-tests/src/test/org/apache/avalon/excalibur/logger/test log4j.xml Log4JConfTestCase.java
cziegeler 2004/05/04 04:14:28
Added: logger/src/java/org/apache/avalon/excalibur/logger
Log4JLoggerManager.java Log4JConfLoggerManager.java
logger-tests/src/test/org/apache/avalon/excalibur/logger/test
log4j.xml Log4JConfTestCase.java
Log:
Readd missing files!
Revision Changes Path
1.20 +18 -52 avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/Log4JLoggerManager.java
1.8 +18 -51 avalon-excalibur/logger/src/java/org/apache/avalon/excalibur/logger/Log4JConfLoggerManager.java
1.1 avalon-excalibur/logger-tests/src/test/org/apache/avalon/excalibur/logger/test/log4j.xml
Index: log4j.xml
===================================================================
<!--
Copyright 2004 The Apache Software Foundation
Licensed 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.
-->
<log4j:configuration>
<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="File" value="System.out"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%p - %m%n"/>
</layout>
</appender>
<root>
<priority value="debug"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
1.1 avalon-excalibur/logger-tests/src/test/org/apache/avalon/excalibur/logger/test/Log4JConfTestCase.java
Index: Log4JConfTestCase.java
===================================================================
/*
* Copyright 2002-2004 The Apache Software Foundation
* Licensed 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.
*/
package org.apache.avalon.excalibur.logger.test;
import java.io.IOException;
import java.io.InputStream;
import junit.framework.TestCase;
import org.apache.avalon.excalibur.logger.Log4JConfLoggerManager;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.xml.sax.SAXException;
/**
*
* @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
* @version $Revision: 1.1 $ $Date: 2004/05/04 11:14:28 $
*/
public class Log4JConfTestCase
extends TestCase
{
public Log4JConfTestCase( final String name )
{
super( name );
}
public void testWrite()
throws Exception
{
final Log4JConfLoggerManager manager = getManager( "log4j.xml" );
final Logger logger = manager.getDefaultLogger();
logger.warn( "Some random message" );
}
private Log4JConfLoggerManager getManager( final String resourceName )
throws Exception
{
final Configuration configuration = loadConfiguration( resourceName );
final Log4JConfLoggerManager manager = new Log4JConfLoggerManager();
ContainerUtil.enableLogging(manager, new ConsoleLogger());
ContainerUtil.configure( manager, configuration );
return manager;
}
private Configuration loadConfiguration( final String resourceName ) throws SAXException, IOException, ConfigurationException
{
final InputStream resource = getResource( resourceName );
final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
final Configuration configuration = builder.build( resource );
return configuration;
}
private InputStream getResource( final String resourceName )
{
final InputStream resource = getClass().getResourceAsStream( resourceName );
if( null == resource )
{
throw new NullPointerException( "resource" );
}
return resource;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org