I have a Maven project with some dependency from a major project. One of those dependency inserts a log4j.xml file into my final jar derived from the build. I had removed all the duplicated dependecies from my project and insert manually log4j (not derived from any other dependecy). But It haven't work, the other log4j file still imports I wanna know how to stop importing this log4j.xml file and get only the log4j from the src/main/resources of the minor project.
I have just a log4j.xml in the resources and no other configuration file.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- Log4j Configuration -->
<!-- Created by Ant. Base file: log4j.xml.unparsed -->
<!-- ===================================================================== -->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A size based rolling appender -->
<appender name="FILEZEUS" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="log/Generate_Curve.log" />
<param name="MaxFileSize" value="10MB" />
<param name="MaxBackupIndex" value="20" />
<param name="Append" value="true" />
<param name="Threshold" value="DEBUG" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> -->
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="DEBUG" />
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n" />
</layout>
</appender>
<logger name="org.apache">
<level value="WARN" />
</logger>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILEZEUS" />
</root>
</log4j:configuration>
Question is still unclear but If you want to load any file from resources then this code will help you.
import java.io.InputStream;
public final class ResourceLoader {
public static InputStream load(String fileName){
InputStream input = ResourceLoader.class.getResourceAsStream(fileName);
if(input==null){
input = ResourceLoader.class.getResourceAsStream("/"+fileName);
}
return input;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.