[LOGBack-dev] svn commit: r483 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic main/java/ch/qos/logback/classic/net main/java/ch/qos/logback/classic/spi test/input/socket test/java/ch/qos/logback/classic/net
noreply.seb at qos.ch
noreply.seb at qos.ch
Thu Aug 24 14:57:26 CEST 2006
Author: seb
Date: Thu Aug 24 14:57:24 2006
New Revision: 483
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
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/spi/LoggingEvent.java
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:
- SocketAppender, on going work.
- Some attributes of Logger have been set transient
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java Thu Aug 24 14:57:24 2006
@@ -10,6 +10,7 @@
package ch.qos.logback.classic;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -24,9 +25,14 @@
import ch.qos.logback.core.spi.AppenderAttachableImpl;
-public final class Logger implements org.slf4j.Logger, AppenderAttachable {
+public final class Logger implements org.slf4j.Logger, AppenderAttachable, Serializable {
/**
+ *
+ */
+ private static final long serialVersionUID = 5454405123156820674L;
+
+ /**
* The fully qualified name of this class. Used in gathering caller
* information.
*/
@@ -57,7 +63,7 @@
*/
private List<Logger> childrenList;
- private AppenderAttachableImpl aai;
+ private transient AppenderAttachableImpl aai;
/**
* Additivity is set to true by default, that is children inherit the
* appenders of their ancestors by default. If this variable is set to
@@ -68,7 +74,7 @@
*/
private boolean additive = true;
- final LoggerContext loggerContext;
+ final transient LoggerContext loggerContext;
Logger(String name, Logger parent, LoggerContext loggerContext) {
this.name = name;
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 14:57:24 2006
@@ -15,6 +15,7 @@
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;
+import java.util.Calendar;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.AppenderBase;
@@ -249,7 +250,10 @@
if (oos != null) {
try {
+ Long t1 = Calendar.getInstance().getTimeInMillis();
oos.writeObject(event);
+ Long t2 = Calendar.getInstance().getTimeInMillis();
+ addInfo("=========Writing time: " + Long.toString(t2-t1));
addInfo("=========Flushing.");
oos.flush();
if (++counter >= RESET_FREQUENCY) {
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java Thu Aug 24 14:57:24 2006
@@ -1,16 +1,18 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
- *
- * Copyright (C) 1999-2005, QOS.ch, LOGBack.com
- *
- * This library is free software, you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation.
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
*/
package ch.qos.logback.classic.spi;
+import java.io.Serializable;
+
import org.slf4j.Logger;
import org.slf4j.Marker;
@@ -19,9 +21,9 @@
/**
* The internal representation of logging events. When an affirmative decision
* is made to log then a <code>LoggingEvent</code> instance is created. This
- * instance is passed around to the different LogBack components.
+ * instance is passed around to the different Logback components.
*
- * <p>Writers of LogBack components such as appenders should be
+ * <p>Writers of Logback components such as appenders should be
* aware of that some of the LoggingEvent fields are initialized lazily.
* Therefore, an appender wishing to output data to be later correctly read
* by a receiver, must initialize "lazy" fields prior to writing them out.
@@ -29,10 +31,15 @@
*
* @author Ceki Gülcü
*/
-public class LoggingEvent {
+public class LoggingEvent implements Serializable {
/**
+ *
+ */
+ private static final long serialVersionUID = -7298433437463204531L;
+
+ /**
*
*/
private static long startTime = System.currentTimeMillis();
@@ -166,7 +173,7 @@
public void setMessage(String message) {
if (this.message != null) {
- throw new IllegalStateException("The message for this event has been set alredy.");
+ throw new IllegalStateException("The message for this event has been set already.");
}
this.message = message;
}
@@ -227,5 +234,7 @@
}
this.marker = marker;
}
+
+
}
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 14:57:24 2006
@@ -9,18 +9,6 @@
</layout>
</appender>
- <appender name="rolling"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <param name="maxFileSize" value="100" />
- </triggeringPolicy>
- <param name="file" value="example.log" />
- <layout class="ch.qos.logback.classic.PatternLayout">
- <param name="pattern" value="SERV: %p %t %c - %m%n" />
- </layout>
- </appender>
-
<root>
<level value="debug" />
<appender-ref ref="stdout" />
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 14:57:24 2006
@@ -4,12 +4,13 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;
-public class SocketAppenderTest {
+public class SocketAppenderTest {
public static void main(String[] args) {
-
+
Logger logger = (Logger) LoggerFactory.getLogger(SocketAppenderTest.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
SocketAppender appender = new SocketAppender("localhost", 4560);
@@ -19,8 +20,12 @@
logger.addAppender(appender);
- logger.debug("************* Hello world.");
+ for (int i = 0; i <= 1000; i++) {
+ logger.debug("** Hello world. n=" + i);
+ }
+
+
+ StatusPrinter.print(lc.getStatusManager());
}
-
}
More information about the logback-dev
mailing list