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

[Dubbo-3361] Make DubboAppender extends from FileAppender #3383

Merged
merged 2 commits into from
Jan 30, 2019
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ script:

after_success:
- bash <(curl -s https://codecov.io/bash)

after_failure:
- if [ -f dubbo.log ]; then echo "------TAIL of dubbo.log------"; tail -n 1000 dubbo.log; echo "------END of dubbo.log------"; fi
1 change: 1 addition & 0 deletions dubbo-cluster/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="DUBBO" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../dubbo.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n"/>
</layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
*/
package org.apache.dubbo.common.utils;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.spi.LoggingEvent;

import java.util.ArrayList;
import java.util.List;

public class DubboAppender extends ConsoleAppender {
public class DubboAppender extends FileAppender {

private static final String DEFAULT_FILE_NAME = "dubbo.log";

public DubboAppender() {
super();
setFile(DEFAULT_FILE_NAME);
}

public static boolean available = false;

public static List<Log> logList = new ArrayList<Log>();
public static List<Log> logList = new ArrayList<>();

public static void doStart() {
available = true;
Expand Down
1 change: 1 addition & 0 deletions dubbo-common/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<!-- 以下是appender的定义 -->
<!-- ===================================================================== -->
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<!-- The following is the definition of appender -->
<!-- ===================================================================== -->
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand All @@ -30,14 +31,8 @@
<param name="LevelMax" value="DEBUG" />
</filter> -->
</appender>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd/MM/yy HH:mm:ss:SSS z}] %5p %c{2}: %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="dubbo"/>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<!-- 以下是appender的定义 -->
<!-- ===================================================================== -->
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand Down
1 change: 1 addition & 0 deletions dubbo-rpc/dubbo-rpc-api/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<!-- 以下是appender的定义 -->
<!-- ===================================================================== -->
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand Down
12 changes: 2 additions & 10 deletions dubbo-rpc/dubbo-rpc-dubbo/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<!-- 以下是appender的定义 -->
<!-- ===================================================================== -->
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand All @@ -30,17 +31,8 @@
<param name="LevelMax" value="DEBUG" />
</filter> -->
</appender>
<appender name="FILE" class="org.apache.log4j.FileAppender">
<param name="File" value="dubbo.log"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- <param name="ConversionPattern" value="[%t %d{dd/MM/yy HH:mm:ss:SSS
z}] %5p %c{2}: %L %m%n" /> -->
<param name="ConversionPattern" value="[%t %l %d{dd/MM/yy HH:mm:ss:SSS z}] %5p %m %n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="dubbo"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
</log4j:configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="dubbo" class="org.apache.dubbo.common.utils.DubboAppender">
<param name="File" value="../../dubbo.log"/>
<param name="encoding" value="GBK"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %p [%c:%M] - %m%n"/>
Expand Down