Wednesday, 10 October 2007

EPiServer Logging & Tail

Any decent developer will know the importance of logging on development machines and in a live environment, so it is worth spending the time setting it up correctly. To get logging initally is easy in EPiServer. just create file in the EPiServer web site directory called EPiServerLog.config and add the following to it to log everything to a file:
<?xml version="1.0" encoding="utf-8" ?>
  <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
    <file value="d:\\logs\\Error-log.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <layout type="log4net.Layout.PatternLayout">
      <param name="ConversionPattern" value="%d\t%X{siteid}\t%m%n" />
    <level value="ALL" />
    <appender-ref ref="FileAppender" />
EPiServer provide a useful article 'Logging in EPiServer' and you can also get more indepth info on log4net and logging to other mediums (such as email) on the log4net site.

Watching log files

If you have nothing better to do than watching log files then Tail for Win32 is perfect for the job. Tail for Win32 is used to monitor changes to files; displaying the changed lines in realtime. This makes Tail ideal for watching log files - and it's free too!


Paul Hallam said...

Check out for a simple but highly effective tool for watching the loggers.
I modified it to take a diffiernt port number from the command line so I could fire off a number for different apps.
Cheers! Paul

Mattias Lövström said...

I think the best way of reading logfiles are with the Unix commands tail and grep, there exists a windows port of a lot of GNU commands at
Example, to get all messages including pageid
tail –f ErrorLog.txt | grep –i pageId