mirror of https://github.com/apache/maven.git
added slf4j-simple logging configuration reinitialization to have
Core ITs run without errors
This commit is contained in:
parent
89c2524458
commit
72bdc8602e
|
@ -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>
|
||||
|
|
|
@ -342,10 +342,10 @@ public class MavenCli
|
|||
// 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() );
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.cli.logging;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -39,8 +37,8 @@ public class BaseSlf4jConfiguration
|
|||
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" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.cli.logging;
|
|||
* 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 interface Slf4jConfiguration
|
|||
*/
|
||||
void setRootLoggerLevel( Level level );
|
||||
|
||||
void setLoggerFile( File output );
|
||||
/**
|
||||
* Activate logging implementation configuration (if necessary).
|
||||
*/
|
||||
void activate();
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.cli.logging.impl;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.cli.logging.BaseSlf4jConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -53,7 +51,7 @@ public class Log4j2Configuration
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setLoggerFile( File output )
|
||||
public void activate()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.cli.logging.impl;
|
|||
* 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 class LogbackConfiguration
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setLoggerFile( File output )
|
||||
public void activate()
|
||||
{
|
||||
// no op
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.apache.maven.cli.logging.impl;
|
|||
* 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 class Slf4jSimpleConfiguration
|
|||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
3
pom.xml
3
pom.xml
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue