# Building log4net

## Contents

Visual Studio
Visual Studio .NET 2002
Visual Studio .NET 2003
Visual Studio 2005
NAnt
Strong Name
SDK Reference
HTML Documentation

The log4net release builds are built using NAnt. Log4net can also be built using Visual Studio .NET 2002, 2003, or 2005.

To build a release build of log4net you will need to create a strong name key file. See the Strong Name section below.

## Visual Studio

Visual Studio .NET 2002, 2003 and 2005 are supported build platforms for log4net.

### Visual Studio .NET 2002

The log4net distribution includes a solution and project file for Visual Studio .NET 2002. Open the log4net.sln from the src directory in the distribution.

The log4net project requires only the following references:

- System
- System.Data
- System.Web
- System.XML

### Visual Studio .NET 2003

Open the Visual Studio .NET 2002 solution file as above. Visual Studio will convert the solution and project files to Visual Studio .NET 2003 format.

After converting the log4net project you must change the Conditional Compilation Constants specified for the log4net project. Open the project properties dialog and select the Configuration Properties/Build sheet. Replace the NET_1_0 constant with NET_1_1. Remember to do this for both Debug and Release configurations.

The log4net project file is not suitable for building log4net for the .NET Compact Framework. To build for the Compact Framework you must create a new C# project for Smart Devices. Configure the project as a library project. Add all the C# files from the src directory in the distribution.

### Visual Studio 2005

Open the Visual Studio .NET 2002 solution file as above. Visual Studio will convert the solution and project files to Visual Studio .NET 2003 format.

After converting the log4net project you must change the Conditional compilation symbols specified for the log4net project. Open the project properties page and select the Build sheet. Replace the NET_1_0 symbol with NET_2_0. Remember to do this for both Debug and Release configurations.

In addition the log4net project requires the following new references:

- System.Configuration

The log4net project file is not suitable for building log4net for the .NET Compact Framework. To build for the Compact Framework you must create a new C# project for Smart Devices. Configure the project as a library project. Add all the C# files from the src directory in the distribution.

## NAnt

The log4net distribution is built using the NAnt tool. A recent NAnt version 0.85 nightly build is required to build log4net, this is available from nant.sourceforge.net.

To support building log4net for the SSCLI framework the NAnt configuration files need to be updated to specify the SSCLI framework directory.

To build log4net from the command line, change directory to the root of the log4net distribution, ensure that the nant executable is in the PATH, and then run the following command:

    nant -buildfile:log4net.build compile-all

This command will build log4net for all the supported frameworks that are available on the current machine. To list all the build targets that are available run the following command:

    nant -buildfile:log4net.build -projecthelp

Under windows the build.cmd can be used to script the nant build. This can be called from a different directory and will locate the correct log4net.build file to use. For example:

    build.cmd compile-all

## Strong Name

In order to build the Release builds of log4net a Strong Name key is required.

Use the sn.exe tool in the .NET Framework SDK to generate a strong name key pair.

    sn -k log4net.snk

The log4net.snk file should be placed in the root of the log4net distribution, in the same folder as the log4net.build file.

## SDK Reference

NDoc 1.3 is used to build the log4net SDK documentation. NDoc is available from ndoc.sourceforge.net.

## HTML Documentation

The log4net HTML documentation is built using Velocity. The source are XML files in the xdocs/src directory. Building the documentation requires Java, Ant, and Velocity. Run ant from within the xdocs directory.

Copyright © 2004-2006, Apache Software Foundation