+ To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ + NOTE: If your receiver application is ever likely to be off-line, don't use TCP protocol + or you'll get TCP timeouts and your application will crawl. + Either switch to UDP transport or use AsyncWrapper target + so that your application threads will not be blocked by the timing-out connection attempts. +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ + NOTE: If your receiver application is ever likely to be off-line, don't use TCP protocol + or you'll get TCP timeouts and your application will crawl. + Either switch to UDP transport or use AsyncWrapper target + so that your application threads will not be blocked by the timing-out connection attempts. +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ + To print the results, use any application that's able to receive messages over + TCP or UDP. NetCat is + a simple but very powerful command-line tool that can be used for that. This image + demonstrates the NetCat tool receiving log messages from Network target. +
+ ++ NOTE: If your receiver application is ever likely to be off-line, don't use TCP protocol + or you'll get TCP timeouts and your application will crawl. + Either switch to UDP transport or use AsyncWrapper target + so that your application threads will not be blocked by the timing-out connection attempts. +
++ There are two specialized versions of the Network target: Chainsaw + and NLogViewer which write to instances of Chainsaw log4j viewer + or NLogViewer application respectively. +
+${longdate}|${level:uppercase=true}|${logger}|${message}
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+
+
+
+
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ ${basedir}/${level}.log
+ All
+ Caution: Enabling this option can considerably slow down your file
+ logging in multi-process scenarios. If only one process is going to
+ be writing to the file, consider setting
+ To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ The result is a message box: +
+ ++ To set up the log target programmatically use code like this: +
+
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + This assumes just one target and a single rule. More configuration + options are described here. +
++ To set up the log target programmatically use code like this: +
+
+ The example web service that works with this example is shown below
+
+ + Asynchronous target wrapper allows the logger code to execute more quickly, by queueing + messages and processing them in a separate thread. You should wrap targets + that spend a non-trivial amount of time in their Write() method with asynchronous + target to speed up logging. +
++ Because asynchronous logging is quite a common scenario, NLog supports a + shorthand notation for wrapping all targets with AsyncWrapper. Just add async="true" to + the <targets/> element in the configuration file. +
+
+
+ ... your targets go here ...
+
+ ]]>
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ + To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ ${longdate}|${level:uppercase=true}|${logger}|${message}
+ This example causes the messages to be written to server1, + and if it fails, messages go to server2.
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes the messages not contains the string '1' to be ignored.
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ + This example works like this. If there are no Warn,Error or Fatal messages in the buffer + only Info messages are written to the file, but if there are any warnings or errors, + the output includes detailed trace (levels >= Debug). You can plug in a different type + of buffering wrapper (such as ASPNetBufferingWrapper) to achieve different + functionality. +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes the messages to be written to either file1.txt or file2.txt + chosen randomly on a per-message basis. +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes each log message to be repeated 3 times.
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes each write attempt to be repeated 3 times, + sleeping 1 second between attempts if first one fails.
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes the messages to be written to either file1.txt or file2.txt. + Each odd message is written to file2.txt, each even message goes to file1.txt. +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ This example causes the messages to be written to both file1.txt or file2.txt +
++ To set up the target in the configuration file, + use the following syntax: +
+
+ + The above examples assume just one target and a single rule. See below for + a programmatic configuration that's equivalent to the above config file: +
+
+ public Inflater(bool noHeader)
passing true
+ if there is no Zlib header information
+
+ The usage is as following. First you have to set some input with
+ SetInput()
, then Inflate() it. If inflate doesn't
+ inflate any bytes there may be three reasons:
+ SetInput()
.
+ NOTE: IsNeedingInput() also returns true when, the stream is finished.
+ SetDictionary()
.setInput(input, 0, input.length)
.
+ setDictionary(dict, 0, dict.Length)
.
+ getValue
. The complete checksum object can also be reset
+ so it can be used again with new data.
+ def.deflate()
until all bytes from the input buffers
+ are processed.
+
+
+ 73739
+ |Malcolm David Kelley|Jorge Garcia|Maggie Grace|...|
+ Thursday
+ 9:00 PM
+ TV-14
+ 2004-09-22
+ |Action and Adventure|Drama|Science-Fiction|
+ tt0411008
+ en
+ ABC
+ After Oceanic Air flight 815...
+ 8.9
+ 60
+ 24313
+ Lost
+ Continuing
+ graphical/24313-g2.jpg
+ fanart/original/73739-1.jpg
+ 1205694666
+ SH672362
+
+
+ - Banner information
+ using System;
+ using System.Text;
+ using System.IO;
+
+ using ICSharpCode.SharpZipLib.Zip;
+
+ class MainClass
+ {
+ public static void Main(string[] args)
+ {
+ using ( ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]))) {
+
+ ZipEntry theEntry;
+ while ((theEntry = s.GetNextEntry()) != null) {
+ int size = 2048;
+ byte[] data = new byte[2048];
+
+ Console.Write("Show contents (y/n) ?");
+ if (Console.ReadLine() == "y") {
+ while (true) {
+ size = s.Read(data, 0, data.Length);
+ if (size > 0) {
+ Console.Write(new ASCIIEncoding().GetString(data, 0, size));
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ NeedsInput()
+ returns true
+
+ strstart + MAX_MATCH <= window.length.
+ prev[index & WMASK]
points to the previous index that has the
+ same hash code as the string starting at index. This way
+ entries with the same hash code are in a linked list.
+ Note that the array should really be unsigned short, so you need
+ to and the values with 0xffff.
+
+ 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}
+
+
+ StringWriter writer = new StringWriter();
+ Layout.Format(writer, loggingEvent);
+ string formattedEvent = writer.ToString();
+
+
+ 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
+
+ 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
+
+