[LOGBack-dev] svn commit: r482 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/net test/input/socket test/java/ch/qos/logback/classic/net
noreply.seb at qos.ch
noreply.seb at qos.ch
Thu Aug 24 10:50:08 CEST 2006
Author: seb
Date: Thu Aug 24 10:50:07 2006
New Revision: 482
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
logback/trunk/logback-classic/src/test/input/socket/clientConfig.xml
logback/trunk/logback-classic/src/test/input/socket/serverConfig.xml
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
Log:
on going work:
- removed Layout from SocketAppender
- modified configFiles and test
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SocketAppender.java Thu Aug 24 10:50:07 2006
@@ -124,8 +124,6 @@
int counter = 0;
- Layout layout;
-
// reset the ObjectOutputStream every 70 calls
// private static final int RESET_FREQUENCY = 70;
private static final int RESET_FREQUENCY = 1;
@@ -140,7 +138,7 @@
this.address = address;
this.remoteHost = address.getHostName();
this.port = port;
- connect(address, port);
+ //connect(address, port);
}
/**
@@ -150,24 +148,37 @@
this.port = port;
this.address = getAddressByName(host);
this.remoteHost = host;
- connect(address, port);
+ //connect(address, port);
}
+ // /**
+ // * Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
+ // */
+ // public void activateOptions() {
+ // connect(address, port);
+ // }
+
/**
- * Connect to the specified <b>RemoteHost</b> and <b>Port</b>.
- */
- public void activateOptions() {
- connect(address, port);
- }
-
- /**
- * Start this appender
+ * Start this appender.
*/
public void start() {
- //TODO More tests before starting the Appender.
- this.started = true;
+ int errorCount = 0;
+ if (port == 0) {
+ errorCount++;
+ addError("No port was configured for appender" + name);
+ }
+
+ if (address == null) {
+ errorCount++;
+ addError("No remote address was configured for appender" + name);
+ }
+
+ connect(address, port);
+
+ if (errorCount == 0) {
+ this.started = true;
+ }
}
-
/**
* Strop this appender.
@@ -226,7 +237,7 @@
@Override
protected void append(Object event) {
-
+
if (event == null)
return;
@@ -337,11 +348,10 @@
}
public Layout getLayout() {
- return layout;
+ return null;
}
public void setLayout(Layout layout) {
- this.layout = layout;
}
/**
Modified: logback/trunk/logback-classic/src/test/input/socket/clientConfig.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/socket/clientConfig.xml (original)
+++ logback/trunk/logback-classic/src/test/input/socket/clientConfig.xml Thu Aug 24 10:50:07 2006
@@ -13,10 +13,7 @@
<appender name="SOCKET"
class="ch.qos.logback.classic.net.SocketAppender">
<param name="remoteHost" value="127.0.0.1" />
- <layout class="ch.qos.logback.classic.PatternLayout">
- <param name="pattern"
- value="SO: %-4relative [%thread] %-5level %class - %msg%n" />
- </layout>
+ <param name="port" value="4560" />
</appender>
<root>
Modified: logback/trunk/logback-classic/src/test/input/socket/serverConfig.xml
==============================================================================
--- logback/trunk/logback-classic/src/test/input/socket/serverConfig.xml (original)
+++ logback/trunk/logback-classic/src/test/input/socket/serverConfig.xml Thu Aug 24 10:50:07 2006
@@ -9,7 +9,7 @@
</layout>
</appender>
- <appender name="Rolling"
+ <appender name="rolling"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
@@ -24,6 +24,6 @@
<root>
<level value="debug" />
<appender-ref ref="stdout" />
- <appender-ref ref="Rolling" />
+ <appender-ref ref="rolling" />
</root>
</configuration>
\ No newline at end of file
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Thu Aug 24 10:50:07 2006
@@ -4,33 +4,23 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.classic.util.Constants;
public class SocketAppenderTest {
public static void main(String[] args) {
-// Thread t = new Thread(new Runnable() {
-// public void run() {
-// SimpleSocketServer.main(new String[]{"4560", Constants.TEST_DIR_PREFIX + "input/socket/serverConfig.xml"});
-// }
-// });
-
-// t.start();
-
Logger logger = (Logger) LoggerFactory.getLogger(SocketAppenderTest.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(lc);
- configurator.doConfigure(Constants.TEST_DIR_PREFIX + "input/socket/clientConfig.xml");
-
+ SocketAppender appender = new SocketAppender("localhost", 4560);
+ appender.setContext(lc);
+ appender.setName("socket");
+ appender.start();
+
+ logger.addAppender(appender);
+
logger.debug("************* Hello world.");
-
-// t.interrupt();
-// System.exit(0);
-
+
}
}
More information about the logback-dev
mailing list