[assembly: InternalsVisibleTo("Full.Name.Of.Testing.Assembly")]
+
+ if (token.IsCancellationRequested)
+ throw new OperationCanceledException(token);
+
+
+ // C#
+ var t = Task<int>.Factory.StartNew(() => GenerateResult());
+ - or -
+ var t = Task.Factory.StartNew(() => GenerateResult());
+
+ ' Visual Basic
+ Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
+ - or -
+ Dim t = Task.Factory.StartNew(Function() GenerateResult())
+
+
+ // C#
+ var t = Task.Factory.StartNew(() => DoAction());
+
+ ' Visual Basic
+ Dim t = Task.Factory.StartNew(Function() DoAction())
+
+
+ if (token.IsCancellationRequested)
+ throw new OperationCanceledException(token);
+
+
+ // C#
+ var t = Task<int>.Factory.StartNew(() => GenerateResult());
+ - or -
+ var t = Task.Factory.StartNew(() => GenerateResult());
+
+ ' Visual Basic
+ Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
+ - or -
+ Dim t = Task.Factory.StartNew(Function() GenerateResult())
+
+
+ // C#
+ var t = Task.Factory.StartNew(() => DoAction());
+
+ ' Visual Basic
+ Dim t = Task.Factory.StartNew(Function() DoAction())
+
+
+ if (token.IsCancellationRequested)
+ throw new OperationCanceledException(token);
+
+
+ // C#
+ var t = Task<int>.Factory.StartNew(() => GenerateResult());
+ - or -
+ var t = Task.Factory.StartNew(() => GenerateResult());
+
+ ' Visual Basic
+ Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
+ - or -
+ Dim t = Task.Factory.StartNew(Function() GenerateResult())
+
+
+ // C#
+ var t = Task.Factory.StartNew(() => DoAction());
+
+ ' Visual Basic
+ Dim t = Task.Factory.StartNew(Function() DoAction())
+
+
+ if (token.IsCancellationRequested)
+ throw new OperationCanceledException(token);
+
+
+ // C#
+ var t = Task<int>.Factory.StartNew(() => GenerateResult());
+ - or -
+ var t = Task.Factory.StartNew(() => GenerateResult());
+
+ ' Visual Basic
+ Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
+ - or -
+ Dim t = Task.Factory.StartNew(Function() GenerateResult())
+
+
+ // C#
+ var t = Task.Factory.StartNew(() => DoAction());
+
+ ' Visual Basic
+ Dim t = Task.Factory.StartNew(Function() DoAction())
+
+
+ if (token.IsCancellationRequested)
+ throw new OperationCanceledException(token);
+
+
+ // C#
+ var t = Task<int>.Factory.StartNew(() => GenerateResult());
+ - or -
+ var t = Task.Factory.StartNew(() => GenerateResult());
+
+ ' Visual Basic
+ Dim t = Task<int>.Factory.StartNew(Function() GenerateResult())
+ - or -
+ Dim t = Task.Factory.StartNew(Function() GenerateResult())
+
+
+ // C#
+ var t = Task.Factory.StartNew(() => DoAction());
+
+ ' Visual Basic
+ Dim t = Task.Factory.StartNew(Function() DoAction())
+
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ /*...*/
containing the specified text.
+ /*...*/
containing the specified text.
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+ /*...*/
containing the specified text.
+
+
+
+
+
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+ Info
will exclude Verbose
messages and include Info
,
+ Warning
and Error
messages.
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(fileToCompress + ".deflated"))
+ {
+ using (Stream compressor = new DeflateStream(raw, CompressionMode.Compress))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(fileToCompress & ".deflated")
+ Using compressor As Stream = New DeflateStream(raw, CompressionMode.Compress)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(fileToCompress + ".deflated"))
+ {
+ using (Stream compressor = new DeflateStream(raw,
+ CompressionMode.Compress,
+ CompressionLevel.BestCompression))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n= -1;
+ while (n != 0)
+ {
+ if (n > 0)
+ compressor.Write(buffer, 0, n);
+ n= input.Read(buffer, 0, buffer.Length);
+ }
+ }
+ }
+ }
+
+
+
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(fileToCompress & ".deflated")
+ Using compressor As Stream = New DeflateStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ using (var output = System.IO.File.Create(fileToCompress + ".deflated"))
+ {
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (Stream compressor = new DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n= -1;
+ while (n != 0)
+ {
+ if (n > 0)
+ compressor.Write(buffer, 0, n);
+ n= input.Read(buffer, 0, buffer.Length);
+ }
+ }
+ }
+ // can write additional data to the output stream here
+ }
+
+
+
+ Using output As FileStream = File.Create(fileToCompress & ".deflated")
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using compressor As Stream = New DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, True)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ ' can write additional data to the output stream here.
+ End Using
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(outputFile))
+ {
+ using (Stream compressor = new GZipStream(raw, CompressionMode.Compress))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+ Dim outputFile As String = (fileToCompress & ".compressed")
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(outputFile)
+ Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ private void GunZipFile(string filename)
+ {
+ if (!filename.EndsWith(".gz))
+ throw new ArgumentException("filename");
+ var DecompressedFile = filename.Substring(0,filename.Length-3);
+ byte[] working = new byte[WORKING_BUFFER_SIZE];
+ int n= 1;
+ using (System.IO.Stream input = System.IO.File.OpenRead(filename))
+ {
+ using (Stream decompressor= new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true))
+ {
+ using (var output = System.IO.File.Create(DecompressedFile))
+ {
+ while (n !=0)
+ {
+ n= decompressor.Read(working, 0, working.Length);
+ if (n > 0)
+ {
+ output.Write(working, 0, n);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+
+ Private Sub GunZipFile(ByVal filename as String)
+ If Not (filename.EndsWith(".gz)) Then
+ Throw New ArgumentException("filename")
+ End If
+ Dim DecompressedFile as String = filename.Substring(0,filename.Length-3)
+ Dim working(WORKING_BUFFER_SIZE) as Byte
+ Dim n As Integer = 1
+ Using input As Stream = File.OpenRead(filename)
+ Using decompressor As Stream = new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, True)
+ Using output As Stream = File.Create(UncompressedFile)
+ Do
+ n= decompressor.Read(working, 0, working.Length)
+ If n > 0 Then
+ output.Write(working, 0, n)
+ End IF
+ Loop While (n > 0)
+ End Using
+ End Using
+ End Using
+ End Sub
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(fileToCompress + ".gz"))
+ {
+ using (Stream compressor = new GZipStream(raw,
+ CompressionMode.Compress,
+ CompressionLevel.BestCompression))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(fileToCompress & ".gz")
+ Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(outputFile))
+ {
+ using (Stream compressor = new GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression, true))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+ Dim outputFile As String = (fileToCompress & ".compressed")
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(outputFile)
+ Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression, True)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ byte[] working = new byte[WORKING_BUFFER_SIZE];
+ using (System.IO.Stream input = System.IO.File.OpenRead(_CompressedFile))
+ {
+ using (Stream decompressor= new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true))
+ {
+ using (var output = System.IO.File.Create(_DecompressedFile))
+ {
+ int n;
+ while ((n= decompressor.Read(working, 0, working.Length)) !=0)
+ {
+ output.Write(working, 0, n);
+ }
+ }
+ }
+ }
+
+
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n= -1;
+ String outputFile = fileToCompress + ".compressed";
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(outputFile))
+ {
+ using (Stream compressor = new ParallelDeflateOutputStream(raw))
+ {
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Dim outputFile As String = (fileToCompress & ".compressed")
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(outputFile)
+ Using compressor As Stream = New ParallelDeflateOutputStream(raw)
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ ParallelDeflateOutputStream deflater = null;
+ foreach (var inputFile in listOfFiles)
+ {
+ string outputFile = inputFile + ".compressed";
+ using (System.IO.Stream input = System.IO.File.OpenRead(inputFile))
+ {
+ using (var outStream = System.IO.File.Create(outputFile))
+ {
+ if (deflater == null)
+ deflater = new ParallelDeflateOutputStream(outStream,
+ CompressionLevel.Best,
+ CompressionStrategy.Default,
+ true);
+ deflater.Reset(outStream);
+
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ deflater.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+ var adler = Adler.Adler32(0, null, 0, 0);
+ adler = Adler.Adler32(adler, buffer, index, length);
+
+
+ private void InflateBuffer()
+ {
+ int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+ ZlibCodec decompressor = new ZlibCodec();
+
+ Console.WriteLine("\n============================================");
+ Console.WriteLine("Size of Buffer to Inflate: {0} bytes.", CompressedBytes.Length);
+ MemoryStream ms = new MemoryStream(DecompressedBytes);
+
+ int rc = decompressor.InitializeInflate();
+
+ decompressor.InputBuffer = CompressedBytes;
+ decompressor.NextIn = 0;
+ decompressor.AvailableBytesIn = CompressedBytes.Length;
+
+ decompressor.OutputBuffer = buffer;
+
+ // pass 1: inflate
+ do
+ {
+ decompressor.NextOut = 0;
+ decompressor.AvailableBytesOut = buffer.Length;
+ rc = decompressor.Inflate(FlushType.None);
+
+ if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
+ throw new Exception("inflating: " + decompressor.Message);
+
+ ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
+ }
+ while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
+
+ // pass 2: finish and flush
+ do
+ {
+ decompressor.NextOut = 0;
+ decompressor.AvailableBytesOut = buffer.Length;
+ rc = decompressor.Inflate(FlushType.Finish);
+
+ if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
+ throw new Exception("inflating: " + decompressor.Message);
+
+ if (buffer.Length - decompressor.AvailableBytesOut > 0)
+ ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
+ }
+ while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
+
+ decompressor.EndInflate();
+ }
+
+
+
+ int bufferSize = 40000;
+ byte[] CompressedBytes = new byte[bufferSize];
+ byte[] DecompressedBytes = new byte[bufferSize];
+
+ ZlibCodec compressor = new ZlibCodec();
+
+ compressor.InitializeDeflate(CompressionLevel.Default);
+
+ compressor.InputBuffer = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToCompress);
+ compressor.NextIn = 0;
+ compressor.AvailableBytesIn = compressor.InputBuffer.Length;
+
+ compressor.OutputBuffer = CompressedBytes;
+ compressor.NextOut = 0;
+ compressor.AvailableBytesOut = CompressedBytes.Length;
+
+ while (compressor.TotalBytesIn != TextToCompress.Length && compressor.TotalBytesOut < bufferSize)
+ {
+ compressor.Deflate(FlushType.None);
+ }
+
+ while (true)
+ {
+ int rc= compressor.Deflate(FlushType.Finish);
+ if (rc == ZlibConstants.Z_STREAM_END) break;
+ }
+
+ compressor.EndDeflate();
+
+
+
+ private void DeflateBuffer(CompressionLevel level)
+ {
+ int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+ ZlibCodec compressor = new ZlibCodec();
+
+ Console.WriteLine("\n============================================");
+ Console.WriteLine("Size of Buffer to Deflate: {0} bytes.", UncompressedBytes.Length);
+ MemoryStream ms = new MemoryStream();
+
+ int rc = compressor.InitializeDeflate(level);
+
+ compressor.InputBuffer = UncompressedBytes;
+ compressor.NextIn = 0;
+ compressor.AvailableBytesIn = UncompressedBytes.Length;
+
+ compressor.OutputBuffer = buffer;
+
+ // pass 1: deflate
+ do
+ {
+ compressor.NextOut = 0;
+ compressor.AvailableBytesOut = buffer.Length;
+ rc = compressor.Deflate(FlushType.None);
+
+ if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
+ throw new Exception("deflating: " + compressor.Message);
+
+ ms.Write(compressor.OutputBuffer, 0, buffer.Length - compressor.AvailableBytesOut);
+ }
+ while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);
+
+ // pass 2: finish and flush
+ do
+ {
+ compressor.NextOut = 0;
+ compressor.AvailableBytesOut = buffer.Length;
+ rc = compressor.Deflate(FlushType.Finish);
+
+ if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
+ throw new Exception("deflating: " + compressor.Message);
+
+ if (buffer.Length - compressor.AvailableBytesOut > 0)
+ ms.Write(buffer, 0, buffer.Length - compressor.AvailableBytesOut);
+ }
+ while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);
+
+ compressor.EndDeflate();
+
+ ms.Seek(0, SeekOrigin.Begin);
+ CompressedBytes = new byte[compressor.TotalBytesOut];
+ ms.Read(CompressedBytes, 0, CompressedBytes.Length);
+ }
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(fileToCompress + ".zlib"))
+ {
+ using (Stream compressor = new ZlibStream(raw, CompressionMode.Compress))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(fileToCompress & ".zlib")
+ Using compressor As Stream = New ZlibStream(raw, CompressionMode.Compress)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (var raw = System.IO.File.Create(fileToCompress + ".zlib"))
+ {
+ using (Stream compressor = new ZlibStream(raw,
+ CompressionMode.Compress,
+ CompressionLevel.BestCompression))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ }
+
+
+
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using raw As FileStream = File.Create(fileToCompress & ".zlib")
+ Using compressor As Stream = New ZlibStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ End Using
+
+
+ using (var output = System.IO.File.Create(fileToCompress + ".zlib"))
+ {
+ using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
+ {
+ using (Stream compressor = new ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true))
+ {
+ byte[] buffer = new byte[WORKING_BUFFER_SIZE];
+ int n;
+ while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ compressor.Write(buffer, 0, n);
+ }
+ }
+ }
+ // can write additional data to the output stream here
+ }
+
+
+ Using output As FileStream = File.Create(fileToCompress & ".zlib")
+ Using input As Stream = File.OpenRead(fileToCompress)
+ Using compressor As Stream = New ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, True)
+ Dim buffer As Byte() = New Byte(4096) {}
+ Dim n As Integer = -1
+ Do While (n <> 0)
+ If (n > 0) Then
+ compressor.Write(buffer, 0, n)
+ End If
+ n = input.Read(buffer, 0, buffer.Length)
+ Loop
+ End Using
+ End Using
+ ' can write additional data to the output stream here.
+ End Using
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+ using log4net.Util;
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.InfoExt("Application Start");
+ log.DebugExt("This is a debug message");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+ using log4net.Util;
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.InfoExt("Application Start");
+ log.DebugExt("This is a debug message");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+ using log4net.Util;
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.InfoExt("Application Start");
+ log.DebugExt("This is a debug message");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ CREATE TABLE [dbo].[Log] (
+ [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ [Date] [datetime] NOT NULL ,
+ [Thread] [varchar] (255) NOT NULL ,
+ [Level] [varchar] (20) NOT NULL ,
+ [Logger] [varchar] (255) NOT NULL ,
+ [Message] [varchar] (4000) NOT NULL
+ ) ON [PRIMARY]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"
+ "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"
+ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"
+ System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for ODBC .NET Data Provider.
+ System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ This is an optional package that you can download from
+ http://msdn.microsoft.com/downloads
+ search for .NET Managed Provider for Oracle.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <mapping>
+ <level value="ERROR" />
+ <eventLogEntryType value="Error" />
+ </mapping>
+ <mapping>
+ <level value="DEBUG" />
+ <eventLogEntryType value="Information" />
+ </mapping>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ UdpClient udpClient;
+ byte[] buffer;
+ string loggingEvent;
+
+ try
+ {
+ udpClient = new UdpClient(8080);
+
+ while(true)
+ {
+ buffer = udpClient.Receive(ref remoteEndPoint);
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ Console.WriteLine(loggingEvent);
+ }
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e.ToString());
+ }
+
+
+ Dim remoteEndPoint as IPEndPoint
+ Dim udpClient as UdpClient
+ Dim buffer as Byte()
+ Dim loggingEvent as String
+
+ Try
+ remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ udpClient = new UdpClient(8080)
+
+ While True
+ buffer = udpClient.Receive(ByRef remoteEndPoint)
+ loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ Console.WriteLine(loggingEvent)
+ Wend
+ Catch e As Exception
+ Console.WriteLine(e.ToString())
+ End Try
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ log4net configuration XML goes here
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ using log4net.Config;
+ using System.IO;
+ using System.Configuration;
+
+ ...
+
+ XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+
+
+
+
+
+
+
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+
+
+ if (isDebugEnabled)
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ log.Debug("This is entry number: " + i );
+
+
+ if (log.IsDebugEnabled())
+ {
+ log.Debug("This is entry number: " + i );
+ }
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ {key1=value1, key2=value2, key3=value3}
+
+
+ ILog log = LogManager.GetLogger(typeof(TestApp));
+ log.Debug("Message 1");
+ log.Warn("Message 2");
+
+
+ DEBUG [main]: Message 1
+ WARN [main]: Message 2
+
+ Format modifier | +left justify | +minimum width | +maximum width | +comment | +
---|---|---|---|---|
%20logger | +false | +20 | +none | +
+ |
+
%-20logger | +true | +20 | +none | +
+ |
+
%.30logger | +NA | +none | +30 | +
+ |
+
false | +20 | +30 | +
+ |
+ |
%-20.30logger | +true | +20 | +30 | +
+ |
+
%timestamp [%thread] %level %logger %ndc - %message%newline
+ %-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ DEBUG - Hello world
+
+
+ <?xml version="1.0" ?>
+
+ <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+
+ <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ &data;
+ </log4net:events>
+
+
+ using log4net.Util;
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.InfoExt("Application Start");
+ log.DebugExt("This is a debug message");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+
+
+ string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+
+
+ using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ {
+ log.Warn("This should have an ThreadContext Stack message");
+ }
+
+
+ GlobalContext.Properties["hostname"] = Environment.MachineName;
+
+
+ LogicalThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a LogicalThreadContext Property called 'user'");
+
+
+ using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ {
+ log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+
+ ILog log = LogManager.GetLogger("application-log");
+
+ log.Info("Application Start");
+ log.Debug("This is a debug message");
+
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("This is another debug message");
+ }
+
+
+ using(NDC.Push("my context message"))
+ {
+ ... all log calls will have 'my context message' included ...
+
+ } // at the end of the using block the message is automatically removed
+
+
+ using(log4net.NDC.Push("NDC_Message"))
+ {
+ log.Warn("This should have an NDC message");
+ }
+
+
+ ThreadContext.Properties["user"] = userName;
+ log.Info("This log message has a ThreadContext Property called 'user'");
+
+
+ using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ {
+ log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+
+ } // at the end of the using block the message is automatically popped
+
+