Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manage too many logger #27

Merged
merged 1 commit into from
Jun 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions hadoop-unit-client/hadoop-unit-client-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<exclusions>
<exclusion>
<artifactId>jackson-module-scala_2.10</artifactId>
<groupId>com.fasterxml.jackson.module</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -39,7 +33,6 @@
<dependency>
<artifactId>jackson-module-scala_2.10</artifactId>
<groupId>com.fasterxml.jackson.module</groupId>
<version>2.6.5</version>
</dependency>

</dependencies>
Expand Down
10 changes: 10 additions & 0 deletions hadoop-unit-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
<artifactId>httpclient</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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 com.github.sakserv.propertyparser;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyParser {

private static final Logger LOG = LoggerFactory.getLogger(PropertyParser.class);

private Properties props = new Properties();
private String propFileName;

public PropertyParser(String propFileName) {
this.propFileName = propFileName;
}

public String getPropFileName() {
return propFileName;
}

public void setPropFileName(String propFileName) {
this.propFileName = propFileName;
}

public String getProperty(String key) {
return props.get(key).toString();
}

public void parsePropsFile() throws IOException {

InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);

try {
if (null != inputStream) {
props.load(inputStream);
} else {
throw new IOException("Could not load property file from the resources directory, trying local");
}
} catch(IOException e) {
LOG.error(e.getMessage());
e.printStackTrace();
try {
inputStream = new FileInputStream(new File(propFileName).getAbsolutePath());
props.load(inputStream);
} catch (IOException ex) {
LOG.error("Could not load property file at " + new File(propFileName).getAbsolutePath());
ex.printStackTrace();
throw ex;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</encoder>
</appender>

<logger name="BlockStateChange" level="OFF"/>
<logger name="BlockManager" level="OFF"/>

<root level="info">
<appender-ref ref="STDOUT" />
Expand Down
25 changes: 0 additions & 25 deletions hadoop-unit-standalone/hadoop-unit-standalone-solr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,6 @@

<plugins>

<!--<plugin>-->
<!--<artifactId>maven-resources-plugin</artifactId>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>copy-resources</id>-->
<!--<phase>validate</phase>-->
<!--<goals>-->
<!--<goal>copy-resources</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<outputDirectory>-->
<!--${basedir}/target/appassembler-jsw/jsw/hadoop-unit-standalone-solr/conf-->
<!--</outputDirectory>-->
<!--<resources>-->
<!--<resource>-->
<!--<directory>src/main/conf</directory>-->
<!--</resource>-->
<!--</resources>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
Expand Down Expand Up @@ -131,8 +108,6 @@
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
</extraArgument>
<extraArgument>-server</extraArgument>
<!--<extraArgument>-XX:+UnlockCommercialFeatures</extraArgument>-->
<!--<extraArgument>-XX:+FlightRecorder</extraArgument>-->
<extraArgument>-XX:+HeapDumpOnOutOfMemoryError</extraArgument>
</extraArguments>
</jvmSettings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
</encoder>
</appender>

<logger name="BlockStateChange" level="OFF"/>
<logger name="BlockManager" level="OFF"/>

<root level="info">
<appender-ref ref="STDOUT" />
Expand Down
6 changes: 6 additions & 0 deletions hadoop-unit-standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<dependency>
<groupId>fr.jetoile.hadoop</groupId>
<artifactId>hadoop-unit-commons</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Loading