Ads by Lake Quincy Media
Gibraltar - Learn about the best analysis tool for NLog

Archive for April, 2010

NLog packaging options

I’m trying to figure out what kind of packaging would be most appropriate for NLog 2.0 and I would like to hear your opinion on this matter.

Given that there are going to be at least 9 supported frameworks (and new ones will likely be added – such as Silverlight for Windows Mobile), putting everything into a single exe/msi is not practical. The size would be huge (about 16 MB in compressed msi/30 MB expanded on disk) and that’s mostly because of API documentation in CHM format which adds around 2MB per framework. The library itself is and will likely remain small and because it’s MSIL it compresses really well.

So here are the options I’m considering (for simplicity I’m omitting the fact that there will be two flavors: Release and Debug and some common packages such as sources):

  1. One package with binaries and documentation for each framework
    1. NLog-2.0-NetFx20.msi / zip
    2. NLog-2.0-NetFx35.msi / zip
    3. NLog-2.0-NetFx40.msi / zip
    4. NLog-2.0-SL2.msi / zip
    5. NLog-2.0-SL3.msi / zip
    6. NLog-2.0-SL4.msi / zip
    7. NLog-2.0-NetCf20.msi / zip
    8. NLog-2.0-NetCf35.msi / zip
    9. NLog-2.0-Mono.msi / zip
  2. One package with binaries and documentation for each version of Visual Studio which would include all the frameworks it supports + separate downloads for individual frameworks:
    1. NLog-2.0-VS2008.msi / zip (would include NetFx20,NetFx35,SL2,SL3,NetCF20,NetCF35)
    2. NLog-2.0-VS2010.msi / zip (would include NetFx20,NetFx35,NetFx40,SL3,SL4)
    3. NLog-2.0-NetFx20.msi / zip
    4. NLog-2.0-NetFx35.msi / zip
    5. NLog-2.0-NetFx40.msi / zip
    6. NLog-2.0-SL2.msi / zip
    7. NLog-2.0-SL3.msi / zip
    8. NLog-2.0-SL4.msi / zip
    9. NLog-2.0-NetCf20.msi / zip
    10. NLog-2.0-NetCf35.msi / zip
    11. NLog-2.0-Mono.msi / zip
  3. One package with binaries and documentation for each family of frameworks:
    1. NLog-2.0-NetFx.msi / zip (would include NetFx20, NetFx35, NetFx40)
    2. NLog-2.0-Silverlight.msi / zip (would include SL2,SL3,SL4)
    3. NLog-2.0-CompactFramework.msi / zip (would include NetCf20, NetCf35)
    4. NLog-2.0-Mono.zip
  4. Only one package with binaries and documentation which would include the most common frameworks only, other frameworks would be available as separate downloads as in option#1
    1. NLog-2.0.msi / zip (would include NetFx35, NetFx40, SL4)
    2. NLog-2.0-NetFx20.msi / zip
    3. NLog-2.0-NetFx35.msi / zip
    4. NLog-2.0-NetFx40.msi / zip
    5. NLog-2.0-SL2.msi / zip
    6. NLog-2.0-SL3.msi / zip
    7. NLog-2.0-SL4.msi / zip
    8. NLog-2.0-NetCf20.msi / zip
    9. NLog-2.0-NetCf35.msi / zip
    10. NLog-2.0-Mono.msi / zip
  5. One big package (msi/zip) with all binaries, but without documentation (about 2.5MB msi, 11MB installed). Documentation would be available online or as a separate download.

Which one of these would you prefer?

Ads by Lake Quincy Media

NLog source code is now on GitHub

NLog source repository can now be found on GitHub:
 http://github.com/jkowalski/NLog

I have also taken a snapshot of NLogViewer and put it there as well:
http://github.com/jkowalski/NLogViewer.

As mentioned earlier, NLogViewer is no longer maintained, so feel free to fork the source code and evolve it on GitHub.

Note that since I’m still learning Git, I’m not retiring Subversion server just yet and will use it for backup in case I mess something up.

UPDATE: My original import turned out to be little messed up, so I deleted it and re-uploaded everything from scratch, this time with proper branch/tag structure. I’m starting to really like Git now that I understand it a little better…

NLog 2.0 for Silverlight 4 and .NET Framework 4.0 preview builds

This week .NET Framework 4.0 and Silverlight 4 have been released. I’ve updated NLog 2.0 to support them and published a new build – very experimental – on CodePlex. One of the biggest updates in Silverlight 4 is support for out-of-browser applications with elevated permissions, which means applications that can access the filesystem.

I’ve put together a tiny sample that shows how to use NLog in Silverlight application. Basically since Silverlight does not have a concept of application configuration file you should configure Silverlight at application startup. In my case I’ve added this code in App.xaml.cs:

private void Application_Startup(object sender, StartupEventArgs e)
{
    InitializeNLog();
    this.RootVisual = new MainPage();
}

private void InitializeNLog()
{
    SimpleConfigurator.ConfigureForTargetLogging(
        new FileTarget()
        {
            FileName = "${specialfolder:MyDocuments}/log.${shortdate}.txt",
            Layout = new CsvLayout()
            {
                Columns =
                {
                    new CsvColumn("Time", "${longdate}"),
                    new CsvColumn("Level", "${level}"),
                    new CsvColumn("Lessage", "${message}"),
                    new CsvColumn("Logger", "${logger}"),
                },
            }
        },
        LogLevel.Debug);
}

The application will produce CSV-formatted log file in Documents folder. The name of the file will be log.CURRENTDATE.txt.

Usage of NLog stays unchanged:

public partial class MainPage : UserControl
{
    private static Logger logger = LogManager.GetCurrentClassLogger();

    public MainPage()
    {
        InitializeComponent();

        // log some events
        this.Loaded += (sender, e) => logger.Info("Page loaded");
        this.LayoutUpdated += (sender, e) => logger.Debug("Layout updated");
        this.SizeChanged += (sender, e) => logger.Debug("Size changed to {0}x{1}", e.NewSize.Width, e.NewSize.Height);
        this.KeyDown += (sender, e) => logger.Debug("Key down '{0}'", e.Key);
        this.Unloaded += (sender, e) => logger.Info("Unloaded");
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        logger.Info("Button clicked");
    }
}

Why not give NLog for Silverlight a try? Go to http://nlog.codeplex.com/releases/view/43702 and download preview bits today and report back any issues.

NLog tutorials added to the Wiki

I did a web search today looking for 3rd-party NLog tutorials and I’ve put some of the links on the NLog Wiki. Some of the articles I found are pretty advanced, and they showcase how NLog can be a part of modern application architectures using AOP, dependency injection and other good engineering techniques.

Enjoy.