Building Examples
Building An Example
A single example can be build by running nant from
the example directory.
For example running nant in the
examples\net\1.0\Tutorials\ConsoleApp\cs directory
will build the C# version of the .NET 1.0 ConsoleApp example.
nant can be run in any directory containing a
nant.build file. The typical behavior of the build file
is to build all projects under the current directory.
For example running nant in the
examples\net\1.1 directory
will build all the examples for the .NET 1.1 platform.
Building All Examples
To build all the examples either run nant in the
examples directory or you can specify the
compile-examples target to the main log4net nant build.
Visual Studio .NET
There are Visual Studio .NET 2002 project files for the .NET 1.0 framework.
The solution files for C# and VB are in the examples\net\1.0
folder.
For the Managed C++ project there is a Visual Studio .NET 2003 project file
in the examples\net\1.1 folder.
Examples
Tutorial - ConsoleApp
ConsoleApp shows how to write a simple console application that initializes
logging and logs various events.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
ConsoleApp.exe from the build output directory.
Tutorial - WebApp
ConsoleApp shows how to write a simple ASP.NET web application that initializes
logging and logs various events.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example you need to have an ASP.NET container application to
host the web application, for example IIS. In IIS create a new virtual
directory pointing to the WebApp src directory. Configure IIS to recognize
this virtual directory as an application. Open up a web browser, navigate to
the virtual directory and to the
WebForm1.aspx page within it.
Remoting - RemotingClient
The RemotingClient application is a simple console application that configures
log4net with the RemotingAppender. This appender will attempt to deliver the
logging events to a remoting listener. This example should be run in conjunction
with the RemotingServer.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
RemotingClient.exe from the build output directory.
Remoting - RemotingServer
The RemotingServer application is a simple console application that listens for
logging events from a remote RemotingAppender and then logs them through the
local log4net instance. This example should be run in conjunction
with the RemotingClient.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
RemotingServer.exe from the build output directory.
While this process is running execute the
RemotingClient.exe program on
the same machine. The logging events from the client are transferred to the server.
Repository - SimpleModule
The SimpleModule is a class library that is intended to be used as part of
the SimpleApp example,
This class library uses the log4net.Config.Repository
attribute to create a separate configuration space from other assemblies.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
This library is intended to be used as part of the SimpleApp example.
Repository - SharedModule
The SharedModule is a class library that is intended to be used as part of
the SimpleApp example,
This class library uses log4net but does not attempt to configure logging.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
This library is intended to be used as part of the SimpleApp example.
Repository - SimpleApp
The SimpleApp example uses the SimpleModule and SharedModule to demonstrate
the ways in which multiple assemblies within the same process may be
separately configured.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
SimpleApp.exe from the build output directory.
Extensibility - EventIDLogApp
The EventIDLogApp example demonstrates using the log4net.Ext.EventID extension.
The extension needs to be built separately from the
extensions\net\1.0\log4net.Ext.EventID directory.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
EventIDLogApp.exe from the build output directory.
Extensibility - TraceLogApp
The TraceLogApp example demonstrates using the log4net.Ext.Trace extension.
The extension needs to be built separately from the
extensions\net\1.0\log4net.Ext.Trace directory.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
TraceLogApp.exe from the build output directory.
SampleAppenders
This project includes the following example appenders.
-
AsyncAppender
-
FastDbAppender
-
FireEventAppender
-
MessageBoxAppender
-
MessageObjectExpanderAppender
-
MsmqAppender
-
PatternFileAppender
-
SimpleSmtpAppender
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
SampleAppendersApp.exe from the build output directory.
SampleLayouts
This project includes the following example layouts.
-
ForwardingLayout
-
LineWrappingLayout
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
To run this example execute
SampleLayoutsApp.exe from the build output directory.
Performance - NotLogging
The NotLogging example benchmarks the performance of log4net logging statements in
user code in various scenarios including when logging is disabled.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.
WmiAppender
The WmiAppender sample shows an example appender that fires events through
Windows Management Instrumentation.
This example is available for the following platforms and languages. If a version
is not available for your chosen platform and language combination then select the
nearest platform for the appropriate language.