Darren Ferguson - Weblog

10 August 2010

Log4net for Umbraco package developers

Filed under: Umbraco - by Darren Ferguson @ 09:00

Note: This information is also posted on the Umbraco Wiki

See also: ismailmayat.wordpress.com/.../

  • Download log4net
  • In your visual studio project add a reference to log4net.dll (use bin\net\2.0\release in the distribution)
  • Open AssemblyInfo.cs in the properties folder of your solution.
  • Add the following attributes:
[assembly:   XmlConfigurator(ConfigFile = @"config\my.log4net.config", Watch = true)]
[assembly: RepositoryAttribute("MyAppName")]

Note: RespositoryAttribute is used to identify a distinct configuration for your unique package/assembly it can be any value you wish but try to avoid conflicts.

By specifiying watch=true in the XmlConfigurator attribute you can modify the logging config during development and it will be automatically reloaded without causing an application restart.

A simple configuration file could be as follows:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>

  <appender name="R" type="log4net.Appender.RollingFileAppender">
    <file value="${TEMP}/myPackage.log" />
    <appendToFile value="true" />
    <maximumFileSize value="1000KB" />
    <maxSizeRollBackups value="2" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%level %thread %logger - %message%newline" />
    </layout>
  </appender>

  <root>
    <level value="DEBUG" />
    <appender-ref ref="R" />
  </root>

</log4net>

The above logs to a file in your system tmp directory - The file is rotated once it reaches 1 MB and the last two versions are maintained. Log4net can log to XML files, databases, email etc and you can define different loggers for different classes and different log targets for different levels of logging. See log4net Manual - Configuration for more details.

In your package classes add a logger declaration, for example:

using System;
using umbraco.BusinessLogic;
using log4net;
using System.Reflection;

namespace Umb.Log4Net
{
    public class Class1 : ApplicationBase
    {
        private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public Class1()
        { 
            log.Debug("application starting up");
        }
    }
}

Note: When releasing Umbraco packages you may want to set your logging levels to NONE or FATAL to stop DEBUG information being logged.

02 August 2010

Umbraco Workflow foundation project: short update

Filed under: Umbraco - by Darren Ferguson @ 00:00

I recently blogged a screencast which demonstrated integration of Microsoft Workflow foundation into Umbraco. Happily, response was positive and I've had a few questions about when it will be available as a package.

To set expectations, the short answer is that it won't.

The implementation I put together works well for a client of mine as well as my own site, but the effort involved in documenting and polishing it so that it could be released as a package isn't insignificant.

On top of that my prototype is based on workflow foundation 3 and MS have now released version 4. There is no backward compatibility and the new version is for .net 4. When you start to throw past present and future versions of Umbraco into the equation you start to come up with silly exponential sums when working out how many versions would need to be maintained.

So, no package I'm afraid.

However: If you'd like to implement workflow in Umbraco and would like to sponsor the project it could happen. Feel free to get in touch and we can talk it through.

16 July 2010

Workflow foundation in Umbraco - Preview

Filed under: Umbraco - by Darren Ferguson @ 09:05

At the Codegarden 2010 workflow open space session I pledged to demo what I had achieved with Workflow foundation and Umbraco. The screencast below is an overview of where I am

PS: When the demo fails in the screencast - I should have left the event checked (without a checked event there is no event to cancel!)

19 June 2010

Two new Umbraco packages

Filed under: Umbraco - by Darren Ferguson @ 13:24

I've released two new Umbraco packages:

Event Viewer Discovers all of the events that are registered within an Umbraco instance and displays them on the dashboard. It finds legacy ActionHandlers as well as new v4 events.

It tells you the method that the event invokes and the DLL and namespace where it is defined. I've found this useful for troubleshooting performance bottlenecks and removing redundant event handlers.

Static HTML export Is a re-write of one of my first ever Umbraco packages (more than 4 years ago!).

The package contains an event handler that fires after a node is published and writes out static HTML plus all of the dependencies (CSS, images, JS ). The project arose from a client requirement to use Umbraco to generate HTML which ultimately gets served up by Apache.

I haven't released a binary of this so you'd need to grab the source an build it.

One year, 13 Umbraco packages. How is that for dare, care share?

02 June 2010

XSL PDF Creator for Umbraco 1.0.1 released

Filed under: Umbraco - by Darren Ferguson @ 08:23

I've created a patch release of XSL PDF Creator for Umbraco. Version 1.0.1 is a result of customer feedback and enhances the product so that existing XSLT Macros in rich text editors can be displayed.

The sample XSLT file now demonstrates how to process RTE Macros.

For more information on XSL PDF Creator for Umbraco visit the our.umbraco project page.

15 May 2010

PDF from Umbraco in 3 Minutes

Filed under: Umbraco - by Darren Ferguson @ 09:10

Here is a quick demonstration of how to generate PDFs from Umbraco using XSL PDF Creator for Umbraco. The whole process should take less than 3 minutes.

Step 1


  • Navigate to the Developer section of Umbraco.
  • Expand the packages node in the tree and click "install local package".
  • Click the browse button and Locate the XSL PDF Creator for Umbraco package.
  • Check the box "I understand the security risks associated with installing a local package".
  • Click the load package button.

Step 2


  • When the next screen appears, read the software license and then check the box labelled I agree.
  • Click the Install package button.

Step 3


  • Wait for the confirmation screen. Then navigate to the settings section of Umbraco.

Step 4


  • Choose a document type and check PDF XSL FO under Allowed Templates.

Step 5


  • Navigate to the Content section of umbraco.
  • Find a node of the type you enabled the template for.
  • In the template dropdown of the properties tab choose PDF XSL FO.
  • Save and publish the node.

Step 6


When you view the page corresponding to the content node it will now be rendered as a PDF. Out of the box this works for any document type that uses bodyText as the alias for it's main Rich text content area.

PDF output can be fully customised by modifying the XSL template.

12 April 2010

Some information about me, my work and Ferguson Moriyama

Filed under: Umbraco; Work; Misc; TeamSite - by Darren Ferguson @ 12:31

I seem to be answering a lot of questions about the way I work recently so I thought I'd write a blog post to clear it all up. The confusion seems to be around how I split my time between Umbraco and TeamSite/LiveSite work and what Ferguson Moriyama is - just a front company for my invoicing or an actual company?

Here is how it all fits together.

Firstly, I'm often on a full time contract. In the last 3 years I've been exceptionally lucky to have a great client (The Bank of New York Mellon) that has kept me busy 9-5 - and no more I gratefully add. This relationship is now drawing to a close.

When I'm on contract, I'm still the MD of Ferguson Moriyama. My company is myself plus 2 other full time employees. My wife is one employee - she takes care of the books and lots of other admin tasks - this isn't income shifting she actually has a full time job. Employee #3 is a full time developer unlike myself he isn't into blogging, social media and developer communities, he just likes to sit in a room and code.

Ferguson Moriyama also makes use of an extensive network of freelancers and contractors - my "little black book" contains 10 people, graphic designers, HTML/CSS gurus, people who build servers etc etc. These people are the best of the best in my opinion - the list has grown slowly over more than a decade and I trust the people on it to deliver excellence every time.

Whatever my day to day commitments at Mellon, I'm still the QA who oversees anything that Ferguson Moriyama delivers. To use an Americanism "the buck stops with me".

So what does Ferguson Moriyama do exactly? Well, a few years back we wrote this rather naff mission statement. Much of it still rings true but it probably needs updating and expanding upon a little.

We do web - applications and content. We are very good at Interwoven (Autonomy) content management products and Umbraco. If these technologies won't contain your application we'll work with ASP.net or (PHP or Perl if you want) to create something that does. Good quality graphic design and user experiences are very important to us.

Here are some reasons that you should work with us:

1. 15 years experience. We've been building the web for that long.

2. We often turn down work. Strange as it may seem this is a good reason to work with us. If we agree to work with you it means we are confident we can deliver you something exceptional within budget and timescales. If we don't have this confidence we'll say no. I won't farm out to unknown/un-trusted 3rd parties so if we can't do the job we'll say so.

3. Quality as standard. You'll never been chasing us for accessibility conformance, valid XHTML, valid CSS etc. We wouldn't deliver anything that didn't conform to current standards.

4. We don't do exploitation - Controversial subject this, but if I offshore work I pay what I would pay someone in the UK to do the job. I also believe in working 9-5 5 days a week and quality of life - no-one who works with/for Ferguson Moriyama will be coding at midnight (unless they really want to). I should stress - no-one who works with Ferguson Moriyama will be taking 2 hour lunches at the pub either!

5. We support the Umbraco community - If you get us to do Umbraco development we'll look for components of your CMS that can be componentised as Umbraco packages. We'll offer a 25% discount on any packages that we create as part of your project so long as they can be open sourced and made available to the Umbraco community.

Finally, one of the most common questions I hear is how do you fit all of those Umbraco packages in? Just how do you have the time? The answer is simple - I code quickly. I've been doing this for so long now - I'm probably faster than someone who hasn't.

10 April 2010

Do you speak French?

Filed under: Misc; TeamSite - by Darren Ferguson @ 09:47

Phone rings:
Me: Hello.
Him: Do you speak French?
Me: No.
Him: Oh, not even a little bit?
Me: No.
Him: Errr, OK so you don't speak any French?
Me: That is an accurate summary of our conversation so far, so what can I.....
Him: [cutting me off] I'm looking for an Interwoven consultant, but they must speak French.
Me: Well, I think we've established that there isn't a conversation to have.
[Long pause]
Him: So you don't speak French....
Me: No.
Him: Do you know anyone who speaks French?
Me: Yes, quite a few people.
Him: Great, well do you think...
[cutting him off]
Me: But not with Interwoven skills.
Him: Oh, well thankyou. Bye.

06 April 2010

UK Government IT incompetence: hmcourts-service.gov.uk

Filed under: Misc - by Darren Ferguson @ 09:34

Prime minister Brown recently proposed a dashboard that allows every citizen to personalise the explosive growth of government services on the web. Personally I think the government should stick to the basics.

Following on from a previous blog post UK Government IT incompetence: fco.gov.uk I'm sad to report another far from satisfying experience, this time with hmcourts-service.gov.uk

I tried to make a simple form submission on the site and received a message along the lines of "We cannot accept your submission at this time: Please try again later". So try again later I did - several times.

Patience exhausted I fired an email off to their customer support team only to receive this exasperating response:

Thank you for your email. If problems persist, please provide your user ID and password and we will investigate the matter further, or, alternatively you can call our helpdesk on the number below who will be able to talk you through it.

Please check for any other error messages.

Please note - your particulars of claim must be no more than 24 lines totalling no more than 1080 characters (including space and punctuation). Also, that the only punctuation you can use is full stops or commas - all other punctuation is treated by our system as illegal characters, including £ and & signs.

Can you confirm which internet browser you are using as the site is only compatible with Internet Explorer at the moment. If you're using another browser you may have to switch to a machine that has Internet Explorer in order to submit your claim.

Now you my readers are more than aware what is wrong with this - on so many levels.

My plea then is to the government. Why in this day and age do you have so many difficulties building a simple website? It isn't difficult. With so many qualified agencies out there why do you continually pick those who are simply useless?

A genuine offer if anyone who commissions government websites stumbles across this post. I will come and see you free of charge and explain the issues with government websites, how they can be addressed at a minimial cost and how to appoint a web manager/commissioner who understands the basics of the web.

05 April 2010

Umbraco, Microsoft and Me: Update and more swag

Filed under: Umbraco - by Darren Ferguson @ 13:07

The video diary below is an update on the Microsoft/Umbraco project I'm taking part in.

I keep on referring to Windows Vista ultimate in the video diary instead of windows 7 ultimate - I'd only had one beer - apologies.

If you can spare the time to watch this then there is more swag available. This time the prize is a copy of this book. To enter watch the video and leave a blog comment answering the following question: Which product that is part of website spark seems to have impressed me most?

Winner randomly selected from correct entries :)

The last winner is also announced in the video