added slf4j-simple logging configuration reinitialization to have

Core ITs run without errors
This commit is contained in:
Hervé Boutemy 2013-01-06 11:50:25 +01:00
parent 89c2524458
commit 72bdc8602e
10 changed files with 90 additions and 20 deletions

View File

@ -74,6 +74,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>

View File

@ -342,10 +342,10 @@ else if ( cliRequest.quiet )
// Ignore
//
}
slf4jConfiguration.setLoggerFile( logFile ); // is it really useful? redirecting stdout/stderr isn't sufficient in all cases?
}
slf4jConfiguration.activate();
plexusLoggerManager = new Slf4jLoggerManager();
slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
}

View File

@ -19,8 +19,6 @@
* under the License.
*/
import java.io.File;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,8 +37,8 @@ public void setRootLoggerLevel( Level level )
logger.warn( "setRootLoggerLevel: operation not supported" );
}
public void setLoggerFile( File output )
public void activate()
{
logger.warn( "setLoggerFile: operation not supported" );
logger.warn( "reset(): operation not supported" );
}
}

View File

@ -19,8 +19,6 @@
* under the License.
*/
import java.io.File;
/**
* Interface for configuration operations on loggers, which are not available in slf4j, then require per-slf4f-binding
* implementation.
@ -38,5 +36,8 @@ public static enum Level { DEBUG, INFO, ERROR }
*/
void setRootLoggerLevel( Level level );
void setLoggerFile( File output );
/**
* Activate logging implementation configuration (if necessary).
*/
void activate();
}

View File

@ -19,8 +19,6 @@
* under the License.
*/
import java.io.File;
import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
/**
@ -53,7 +51,7 @@ public void setRootLoggerLevel( Level level )
}
@Override
public void setLoggerFile( File output )
public void activate()
{
// no op
}

View File

@ -19,8 +19,6 @@
* under the License.
*/
import java.io.File;
import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,7 +53,7 @@ public void setRootLoggerLevel( Level level )
}
@Override
public void setLoggerFile( File output )
public void activate()
{
// no op
}

View File

@ -19,9 +19,9 @@
* under the License.
*/
import java.io.File;
import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
import org.slf4j.MavenSlf4jFriend;
import org.slf4j.impl.MavenSlf4jSimpleFriend;
/**
* Configuration for slf4j-simple.
@ -53,8 +53,10 @@ public void setRootLoggerLevel( Level level )
}
@Override
public void setLoggerFile( File output )
public void activate()
{
//System.setProperty( "org.slf4j.simpleLogger.logFile", output.getAbsolutePath() );
// property for root logger level or System.out redirection need to be taken into account
MavenSlf4jFriend.reset();
MavenSlf4jSimpleFriend.init();
}
}

View File

@ -0,0 +1,35 @@
package org.slf4j;
/*
* 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.
*/
/**
* Utility for Maven to access Slf4j internals through package access.
* Use with precaution, since this is not normally intended for production use.
*/
public class MavenSlf4jFriend
{
/**
* Reset Slf4j internal state.
*/
public static void reset()
{
LoggerFactory.reset();
}
}

View File

@ -0,0 +1,32 @@
package org.slf4j.impl;
/*
* 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.
*/
/**
* Utility for Maven to access Slf4j-Simple internals through package access.
* Use with precaution, since this is not normally intended for production use.
*/
public class MavenSlf4jSimpleFriend
{
public static void init()
{
SimpleLogger.init();
}
}

View File

@ -211,12 +211,13 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
<optional>true</optional>
</dependency>
<!-- Wagon -->
<dependency>