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); }
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); }
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); }