Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Some thoughts:</p> <p><a href="http://www.csharp-examples.net/create-windows-service/" rel="nofollow noreferrer">Create windows service with VS 2005</a></p> <p><a href="http://www.csharp-examples.net/install-net-service/" rel="nofollow noreferrer">install .Net Service</a></p> <p>I wrote some couple of years ago a Perl based set of executables ( theads ) etc. , which seems to have similar requirements to yours ... </p> <p>Some stuff to keep in mind: </p> <ul> <li>do have debuggin switch ( you should have one when something goes really wrong ) </li> <li>output to both console and files ( try log4net for example ) </li> <li>build your logging with future regex parsing in mind</li> <li>if there are some inderdependant processes , learn how to kill them , stop and restart them </li> <li>if there are some inderdependant processes try to communicate to them </li> </ul> <p>Here is a small Console example to output to db, file and console with log4net</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using log4net; using log4net.Config; using NUnit.Framework; namespace ExampleConsoleApplication { [TestFixture] class TestClass { //private static readonly ILog logger = // LogManager.GetLogger ( typeof ( TestClass ) ); private static readonly log4net.ILog logger = log4net.LogManager.GetLogger ( System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType ); static void Main ( string[] args ) { Console.WriteLine ( " START " ); #region LoggerUsage DOMConfigurator.Configure (); //tis configures the logger logger.Debug ( "Here is a debug log." ); logger.Info ( "... and an Info log." ); logger.Warn ( "... and a warning." ); logger.Error ( "... and an error." ); logger.Fatal ( "... and a fatal error." ); #endregion LoggerUsage TestClass objTestClass = new TestClass(); objTestClass.TestMethodNameOK (); objTestClass.TestMethodNameNOK (); Console.WriteLine ( " END HIT A KEY TO EXIT " ); Console.ReadLine (); } //eof method [SetUp] protected void SetUp () { //Add Here the Initialization of the objects } [Test ( Description = "Add here the description of this test method " )] protected void TestMethodNameOK () { //build ok use case scenario here - e.g. no exception should be raced ' //Vegetable newCarrot = pool.GetItemByPropertyValue&lt;Vegetable&gt; ( "WriongByPurpose", "Orange" ); //Assert.IsInstanceOfType ( typeof ( Vegetable ), newCarrot ); //Assert.AreSame ( newCarrot, carrot ); //logger.Info ( " I got the newCarrot which is " + newCarrot.Color ); } //eof method [Test ( Description = "Add here the description of this test method " )] protected void TestMethodNameNOK () //e.g. the one that should raze Exception { //build ok use case scenario here - e.g. no exception should be raced ' //Vegetable newCarrot = pool.GetItemByPropertyValue&lt;Vegetable&gt; ( "WriongByPurpose", "Orange" ); //Assert.IsInstanceOfType ( typeof ( Vegetable ), newCarrot ); //Assert.AreSame ( newCarrot, carrot ); //logger.Info ( " I got the newCarrot which is " + newCarrot.Color ); } //eof method } //eof class } //eof namespace #region TheAppConfig // &lt;?xml version="1.0" encoding="utf-8" ?&gt; //&lt;configuration&gt; // &lt;configSections&gt; // &lt;section name="log4net" // type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt; // &lt;/configSections&gt; // &lt;log4net&gt; // &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt; // &lt;param name="File" value="Program.log" /&gt; // &lt;param name="AppendToFile" value="true" /&gt; // &lt;layout type="log4net.Layout.PatternLayout"&gt; // &lt;!--&lt;param name="Header" value="======================================" /&gt; // &lt;param name="Footer" value="======================================" /&gt;--&gt; // &lt;param name="ConversionPattern" value="%d [%t] %-5p - %m%n" /&gt; // &lt;/layout&gt; // &lt;/appender&gt; // &lt;appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"&gt; // &lt;mapping&gt; // &lt;level value="ERROR" /&gt; // &lt;foreColor value="Red" /&gt; // &lt;/mapping&gt; // &lt;mapping&gt; // &lt;level value="DEBUG" /&gt; // &lt;foreColor value="HighIntensity" /&gt; // &lt;/mapping&gt; // &lt;mapping&gt; // &lt;level value="INFO" /&gt; // &lt;foreColor value="Green" /&gt; // &lt;/mapping&gt; // &lt;mapping&gt; // &lt;level value="WARN" /&gt; // &lt;foreColor value="Yellow" /&gt; // &lt;/mapping&gt; // &lt;mapping&gt; // &lt;level value="FATAL" /&gt; // &lt;foreColor value="White" /&gt; // &lt;backColor value="Red" /&gt; // &lt;/mapping&gt; // &lt;layout type="log4net.Layout.PatternLayout"&gt; // &lt;conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /&gt; // &lt;/layout&gt; // &lt;/appender&gt; // &lt;appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"&gt; // &lt;connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.2.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt; // &lt;connectionString value="data source=ysg;initial catalog=DBGA_DEV;integrated security=true;persist security info=True;" /&gt; // &lt;commandText value="INSERT INTO [DBGA_DEV].[ga].[tb_Data_Log] ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" /&gt; // &lt;parameter&gt; // &lt;parameterName value="@log_date" /&gt; // &lt;dbType value="DateTime" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%date{yyyy'.'MM'.'dd HH':'mm':'ss'.'fff}" /&gt; // &lt;/parameter&gt; // &lt;parameter&gt; // &lt;parameterName value="@thread" /&gt; // &lt;dbType value="String" /&gt; // &lt;size value="255" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%thread" /&gt; // &lt;/parameter&gt; // &lt;parameter&gt; // &lt;parameterName value="@domainName" /&gt; // &lt;dbType value="String" /&gt; // &lt;size value="255" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%user" /&gt; // &lt;/parameter&gt; // &lt;parameter&gt; // &lt;parameterName value="@log_level" /&gt; // &lt;dbType value="String" /&gt; // &lt;size value="50" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%level" /&gt; // &lt;/parameter&gt; // &lt;parameter&gt; // &lt;parameterName value="@logger" /&gt; // &lt;dbType value="String" /&gt; // &lt;size value="255" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%logger" /&gt; // &lt;/parameter&gt; // &lt;parameter&gt; // &lt;parameterName value="@message" /&gt; // &lt;dbType value="String" /&gt; // &lt;size value="4000" /&gt; // &lt;layout type="log4net.Layout.PatternLayout" value="%message" /&gt; // &lt;/parameter&gt; // &lt;/appender&gt; // &lt;root&gt; // &lt;level value="ALL" /&gt; // &lt;appender-ref ref="LogFileAppender" /&gt; // &lt;appender-ref ref="AdoNetAppender" /&gt; // &lt;appender-ref ref="ColoredConsoleAppender" /&gt; // &lt;/root&gt; // &lt;/log4net&gt; //&lt;/configuration&gt; #endregion TheAppconfig //this is the xml added replace here your log4net and Nunit paths //&lt;Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"&gt; // &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt; // &lt;HintPath&gt;..\..\..\Log4Net\log4net-1.2.10\bin\net\2.0\release\log4net.dll&lt;/HintPath&gt; //&lt;/Reference&gt; //&lt;Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" /&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload