Exemple #1
0
        static void serverSocketTest()
        {
            var formatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                var logMessage = formatter.FormatMessage(logger, logLevel, message);
                var coloredLogMessage = colorFormatter.FormatMessage(logLevel, logMessage);
                socket.Send(logLevel, coloredLogMessage);
            }));

            socket.Listen(1234);
        }
Exemple #2
0
        static void clientSocketTest()
        {
            var formatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                var logMessage = formatter.FormatMessage(logger, logLevel, message);
                var coloredLogMessage = colorFormatter.FormatMessage(logLevel, logMessage);
                socket.Send(logLevel, coloredLogMessage);
            }));

            Log.Trace("History");
            socket.Connect(IPAddress.Loopback, 1234);
            Thread.Sleep(50);
        }
Exemple #3
0
        void setupExamaple()
        {
            // Setup appender
            var defaultFormatter = new DefaultLogMessageFormatter();
            var colorFormatter = new ColorCodeFormatter();
            var socket = new SocketAppender();
            LoggerFactory.AddAppender(((logger, logLevel, message) => {
                message = defaultFormatter.FormatMessage(logger, logLevel, message);
                message = colorFormatter.FormatMessage(logLevel, message);
                socket.Send(logLevel, message);
            }));

            // Setup as client
            socket.Connect(IPAddress.Loopback, 1234);

            // Or setup as server
            // socket.Listen(1234);
        }