Joel Bennett published a module for logging via log4net. It is something I always wanted to do, but haven't time for it. Besides that, I wouldn't write it in such a quality as he did ;)

However, what I'm missing there is an ability to send a log message to udp port. It is great for application development. You can see in real-time what your application is doing. You can watch on what command it is waiting etc. And – you work with the messages in a much quicker way. No file opening, no search, you can filter the messages. But wait … is there any application that can read the messages?

Yes! I created a form application that can read the udp messages several years ago. Old, but still does its job well. There is an older description written in czech. Maybe automatic translation could help english readers.
In short it is able to show the messages in a grid. You can filter them so that only e.g. level warning and higher is displayed. You can swallow some messages based on regex or show them in a custom color.

Look at it in action how it works with Logger module by Joel.

Edit your Logger module

To get it working, you need to edit the module and add ability to log on a udp port.

  • To Get-Logger add switch
  • Edit the Get-Logger function so that it looks like this:
    if($RollingFile) { $AppenderRefs +=  "<appender-ref ref=""RollingFileAppender"" />`n" }
    if($Udp)         { $AppenderRefs +=  "<appender-ref ref=""udpAppender"" />`n" } # new line
  • Add appender to the embedded configuration xml. You have to add it like this:
    <appender name="udpAppender" type="log4net.Appender.UdpAppender">
      <param name="RemoteAddress" value="" />
      <param name="RemotePort" value="8080" />
      <param name="Encoding" value="utf-8" />
      <layout type="log4net.Layout.XmlLayout">
        <param name="Prefix" value="" />
      <param name="threshold" value="DEBUG" />
    </appender> <!-- new part -->
      <level value="DEBUG" />
    <logger name="$LoggerName">
      <level value="$LogLevel" />
    Note that it uses port 8080. The application has to listen on the same port.
  • And of course use it when calling Get-Logger
    $script:Logger = Get-Logger "PowerShellLogger" -Udp


Meta: 2010-04-08, Pepa