Pages

Friday, 23 April 2010

Using Log4Net

My search is to find simple way to use Log4Net in .NET application was futile. Finally, I decided to write sample code on my own :-)

Step 1: Add reference to log4net.dll in your project (Project -> Add Reference -> Browse)
Step 2: Add application configuration file (Project -> Resources -> Add new item -> app.config)
Step 3: Add below in your app.config file in tag


















The above example shows configuration to the RollingFileAppender to write to the file log.txt. The file written to will always be called log.txt because the StaticLogFileName param is specified. The file will be rolled based on a size constraint (RollingStyle). Up to 10 (MaxSizeRollBackups) old files of 100 KB each (MaximumFileSize) will be kept. These rolled files will be named: log.txt.1, log.txt.2, log.txt.3, etc..







Step 4: Initialize log object as below

dim log as log4Net.ILog

log = log4net.LogManager.GetLogger("Emailer")
log4net.Config.XmlConfigurator.Configure()
log.Debug("Debug message")

Simple, isn't it?

Thursday, 15 April 2010

Unable to find manifest signing certificate in the certificate store

While developing Softphone application using VS 2008, I moved a project from one computer to a different one. When I then tried to rebuild the solution I received the following error:

"Unable to find manifest signing certificate in the certificate store"

As I was sure that I wasn't using any certificate to sign the assembly I couldn't understand the reason for this error message. It turned out that I had to manually go into the *.vbproj file and remove the following four lines that were apparently left over from some past experiments with signing using a certificate:

<manifestcertificatethumbprint>...</manifestcertificatethumbprint>
<manifestkeyfile>...</manifestkeyfile>
<generatemanifests>...</generatemanifests>
<signmanifests>...</signmanifests>

After I had removed those lines I reloaded the project and the solution rebuilt just fine.