Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add

  • Loading branch information...
commit 861e2972b0dd7c534e9404fcc2d0e07fcbb2cd7d 0 parents
@jkowalski authored
Showing with 5,755 additions and 0 deletions.
  1. +32 −0 LICENSE.txt
  2. +157 −0 NLog.FxCop
  3. +162 −0 NLog.build
  4. +56 −0 NLog.sln
  5. +1 −0  NLog.version
  6. +132 −0 doc/index.html
  7. +121 −0 doc/prettyprint.js
  8. +82 −0 doc/style.css
  9. +55 −0 src/NLog.ASPNet/Appenders/ASPNetTraceAppender.cs
  10. +45 −0 src/NLog.ASPNet/AssemblyInfo.cs
  11. +40 −0 src/NLog.ASPNet/AssemblySign.cs
  12. +61 −0 src/NLog.ASPNet/LayoutAppenders/ASPNetRawUrlLayoutAppender.cs
  13. +65 −0 src/NLog.ASPNet/LayoutAppenders/ASPNetSessionValueLayoutAppender.cs
  14. +120 −0 src/NLog.ASPNet/NLog.ASPNet.csproj
  15. +45 −0 src/NLog.ComInterop/AssemblyInfo.cs
  16. +40 −0 src/NLog.ComInterop/AssemblySign.cs
  17. +54 −0 src/NLog.ComInterop/ILogger.cs
  18. +128 −0 src/NLog.ComInterop/Logger.cs
  19. +110 −0 src/NLog.ComInterop/NLog.ComInterop.csproj
  20. +19 −0 src/NLog.Test/App.config
  21. +94 −0 src/NLog.Test/NLog.Test.csproj
  22. +72 −0 src/NLog.Test/Test.cs
  23. +107 −0 src/NLog.Win32/LayoutAppenders/Registry.cs
  24. +95 −0 src/NLog.Win32/NLog.Win32.csproj
  25. BIN  src/NLog.snk
  26. +92 −0 src/NLog/Appender.cs
  27. +44 −0 src/NLog/Appenders/ConsoleAppender.cs
  28. +161 −0 src/NLog/Appenders/FileAppender.cs
  29. +54 −0 src/NLog/Appenders/MemoryAppender.cs
  30. +59 −0 src/NLog/Appenders/NullAppender.cs
  31. +51 −0 src/NLog/Appenders/TraceAppender.cs
  32. +56 −0 src/NLog/AssemblyInfo.cs
  33. +40 −0 src/NLog/AssemblySign.cs
  34. +195 −0 src/NLog/Config/AppenderRule.cs
  35. +53 −0 src/NLog/Config/ConfigSectionHandler.cs
  36. +77 −0 src/NLog/Config/LoggingConfiguration.cs
  37. +270 −0 src/NLog/Config/XmlLoggingConfiguration.cs
  38. +130 −0 src/NLog/Layout.cs
  39. +87 −0 src/NLog/LayoutAppender.cs
  40. +52 −0 src/NLog/LayoutAppenderAttribute.cs
  41. +150 −0 src/NLog/LayoutAppenderFactory.cs
  42. +79 −0 src/NLog/LayoutAppenders/BaseDir.cs
  43. +112 −0 src/NLog/LayoutAppenders/CallSite.cs
  44. +68 −0 src/NLog/LayoutAppenders/Date.cs
  45. +67 −0 src/NLog/LayoutAppenders/Environment.cs
  46. +125 −0 src/NLog/LayoutAppenders/Identity.cs
  47. +122 −0 src/NLog/LayoutAppenders/Level.cs
  48. +57 −0 src/NLog/LayoutAppenders/Literal.cs
  49. +53 −0 src/NLog/LayoutAppenders/LoggerName.cs
  50. +53 −0 src/NLog/LayoutAppenders/LongDate.cs
  51. +57 −0 src/NLog/LayoutAppenders/MachineName.cs
  52. +52 −0 src/NLog/LayoutAppenders/Message.cs
  53. +90 −0 src/NLog/LayoutAppenders/NLogDir.cs
  54. +71 −0 src/NLog/LayoutAppenders/ProcessTime.cs
  55. +53 −0 src/NLog/LayoutAppenders/ShortDate.cs
  56. +54 −0 src/NLog/LayoutAppenders/ThreadName.cs
  57. +52 −0 src/NLog/LayoutAppenders/Ticks.cs
  58. +101 −0 src/NLog/LogEventInfo.cs
  59. +45 −0 src/NLog/LogLevel.cs
  60. +141 −0 src/NLog/LogManager.cs
  61. +137 −0 src/NLog/Logger.cs
  62. +140 −0 src/NLog/LoggerImpl.cs
  63. +270 −0 src/NLog/NLog.csproj
  64. +48 −0 src/NLog/NullLogger.cs
  65. +23 −0 src/NLog/PropertyHelper.cs
  66. +122 −0 tools/ReplaceVersion.cs
  67. BIN  tools/ReplaceVersion.exe
  68. +11 −0 webtest/default.aspx
  69. +61 −0 webtest/global.asax
  70. +27 −0 webtest/web.config
32 LICENSE.txt
@@ -0,0 +1,32 @@
+
+Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of the Jaroslaw Kowalski nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
157 NLog.FxCop
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FxCopProject Version="1.3" Name="NLog">
+ <ProjectOptions>
+ <SharedProject>False</SharedProject>
+ <Stylesheet Apply="False">c:\program files\microsoft fxcop 1.30\Xml\FxCopReport.Xsl</Stylesheet>
+ <SaveMessages>
+ <Project Status="Active, Excluded" NewOnly="False" />
+ <Report Status="Active" NewOnly="False" />
+ </SaveMessages>
+ <ProjectFile Compress="True" DefaultTargetCheck="True" DefaultRuleCheck="True" SaveByRuleGroup="" Deterministic="False" />
+ <PermitAnalysis>True</PermitAnalysis>
+ <SourceLookup>True</SourceLookup>
+ <AnalysisExceptionsThreshold>100</AnalysisExceptionsThreshold>
+ <RuleExceptionsThreshold>10</RuleExceptionsThreshold>
+ <Spelling Locale="en-us" />
+ </ProjectOptions>
+ <Targets>
+ <AssemblyReferenceDirectories>
+ <Directory>D:\Work\NLog\src\NLog.Test\bin\Debug\</Directory>
+ </AssemblyReferenceDirectories>
+ <Target Name="D:\Work\NLog\src\NLog\bin\Debug\NLog.dll" Analyze="True" AnalyzeAllChildren="True" />
+ </Targets>
+ <Rules>
+ <RuleFiles>
+ <RuleFile Name="$(FxCopDir)\Rules\PerformanceRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\ComRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\UsageRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\SecurityRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\DesignRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\GlobalizationRules.dll" Enabled="True" AllRulesEnabled="True" />
+ <RuleFile Name="$(FxCopDir)\Rules\NamingRules.dll" Enabled="True" AllRulesEnabled="True" />
+ </RuleFiles>
+ <Groups />
+ <Settings />
+ </Rules>
+ <FxCopReport Version="1.3" LastAnalysis="2004-08-08 19:35:40Z">
+ <Targets>
+ <Target Name="D:\Work\NLog\src\NLog\bin\Debug\NLog.dll">
+ <Modules>
+ <Module Name="nlog.dll">
+ <Namespaces>
+ <Namespace Name="NLog.LayoutAppenders">
+ <Classes>
+ <Class Name="LevelLayoutAppender">
+ <Constructors>
+ <Constructor Name=".cctor()">
+ <Messages>
+ <Message Status="Excluded" Created="2004-08-08 14:08:05Z">
+ <Rule TypeName="DoNotDeclareExplicitStaticConstructors" />
+ <Issues>
+ <Issue Certainty="90" Level="CriticalWarning">
+ <SourceCode Path="D:\Work\NLog\src\NLog\LayoutAppenders" File="Level.cs" Line="16" />
+ <Resolution>
+ <Data>
+ <Items>
+ <Item>LevelLayoutAppender</Item>
+ </Items>
+ </Data>
+ </Resolution>
+ </Issue>
+ </Issues>
+ </Message>
+ </Messages>
+ </Constructor>
+ </Constructors>
+ </Class>
+ </Classes>
+ </Namespace>
+ <Namespace Name="NLog">
+ <Classes>
+ <Class Name="LayoutAppenderFactory">
+ <Constructors>
+ <Constructor Name=".cctor()">
+ <Messages>
+ <Message Status="Excluded" Created="2004-08-08 14:08:05Z">
+ <Rule TypeName="DoNotDeclareExplicitStaticConstructors" />
+ <Issues>
+ <Issue Certainty="90" Level="CriticalWarning">
+ <SourceCode Path="d:\work\nlog\src\nlog" File="layoutappenderfactory.cs" Line="12" />
+ <Resolution>
+ <Data>
+ <Items>
+ <Item>LayoutAppenderFactory</Item>
+ </Items>
+ </Data>
+ </Resolution>
+ </Issue>
+ </Issues>
+ </Message>
+ </Messages>
+ </Constructor>
+ </Constructors>
+ </Class>
+ </Classes>
+ <ValueTypes>
+ <ValueType Name="LogEventInfo">
+ <Messages>
+ <Message Status="Excluded" Created="2004-08-08 14:08:05Z">
+ <Rule TypeName="ConsiderOverridingEqualsAndOperatorEqualsOnValueTypes" />
+ <Issues>
+ <Issue Certainty="75" Level="Warning">
+ <Resolution>
+ <Data>
+ <Id>Equals</Id>
+ <Items>
+ <Item>LogEventInfo</Item>
+ </Items>
+ </Data>
+ </Resolution>
+ </Issue>
+ <Issue Certainty="75" Level="Warning">
+ <Resolution>
+ <Data>
+ <Id>op_equality</Id>
+ <Items>
+ <Item>LogEventInfo</Item>
+ </Items>
+ </Data>
+ </Resolution>
+ </Issue>
+ </Issues>
+ </Message>
+ </Messages>
+ </ValueType>
+ </ValueTypes>
+ </Namespace>
+ </Namespaces>
+ </Module>
+ </Modules>
+ </Target>
+ </Targets>
+ <Rules>
+ <Rule TypeName="ConsiderOverridingEqualsAndOperatorEqualsOnValueTypes">
+ <Name>Consider overriding Equals and the equality operator on value types</Name>
+ <Description>The default System.ValueType implementation might not perform as well as a custom implementation.</Description>
+ <LongDescription />
+ <GroupOwner>MS FxCopDev</GroupOwner>
+ <DevOwner />
+ <Url>http://www.gotdotnet.com/team/fxcop/docs/rules/Performance/EqualsAndOperatorEqualsOnValueTypes.html</Url>
+ <Email>askfxcop@microsoft.com</Email>
+ <MessageLevel Certainty="75">Warning</MessageLevel>
+ <File Name="PerformanceRules.dll" Version="1.30.0.0" />
+ </Rule>
+ <Rule TypeName="DoNotDeclareExplicitStaticConstructors">
+ <Name>Do not declare explicit static constructors</Name>
+ <Description>Static fields should be initialized when declared.</Description>
+ <LongDescription>Initializing static data in explicit static constructors results in less performant code.</LongDescription>
+ <GroupOwner>MS FxCopDev</GroupOwner>
+ <DevOwner />
+ <Url>http://www.gotdotnet.com/team/fxcop/docs/rules/Performance/DoNotDeclareExplicitStaticConstructors.html</Url>
+ <Email>askfxcop@microsoft.com</Email>
+ <MessageLevel Certainty="90">CriticalWarning</MessageLevel>
+ <File Name="PerformanceRules.dll" Version="1.30.0.0" />
+ </Rule>
+ </Rules>
+ </FxCopReport>
+</FxCopProject>
162 NLog.build
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<project default="build">
+ <property name="nlog.debug" value="true" />
+ <property name="nlog.define" value="NANT" />
+
+ <target name="configure">
+ <call target="configure-${framework::get-target-framework()}" />
+ <property name="output.dir" value="${nant.project.basedir}/bin/${framework::get-target-framework()}${if(nlog.debug,'-debug','')}" unless="${property::exists('output.dir')}" />
+ <mkdir dir="${output.dir}" />
+ </target>
+
+ <target name="build" depends="configure">
+ <call target="build-${framework::get-target-framework()}" />
+ </target>
+
+ <target name="debug">
+ <property name="nlog.debug" value="true" />
+ </target>
+
+ <target name="release">
+ <property name="nlog.debug" value="false" />
+ </target>
+
+ <target name="package" depends="build">
+ <mkdir dir="${nant.project.basedir}/dist" />
+ <property name="zip.file" value="${nant.project.basedir}/dist/NLog-${framework::get-target-framework()}${if(nlog.debug,'-debug','')}.zip" />
+ <zip zipfile="${zip.file}">
+ <fileset basedir="${output.dir}">
+ <include name="*.dll" />
+ <include name="*.pdb" />
+ </fileset>
+ </zip>
+ </target>
+
+ <target name="clean" depends="configure">
+ <delete>
+ <fileset basedir="${output.dir}">
+ <include name="*.dll" />
+ <include name="*.pdb" />
+ <include name="*.xml" />
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="NLog" depends="configure">
+ <csc target="library" output="${output.dir}/NLog.dll" define="${nlog.define}" debug="${nlog.debug}">
+ <sources basedir="src/NLog">
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="mscorlib.dll" />
+ <include name="System.dll" />
+ <include name="System.Xml.dll" />
+ </references>
+ </csc>
+ </target>
+
+ <target name="NLog.ComInterop" depends="NLog">
+ <csc target="library" output="${output.dir}/NLog.ComInterop.dll" define="${nlog.define}" debug="${nlog.debug}">
+ <sources basedir="src/NLog.ComInterop">
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${output.dir}/NLog.dll" />
+ <include name="mscorlib.dll" />
+ <include name="System.dll" />
+ <include name="System.Xml.dll" />
+ </references>
+ </csc>
+ </target>
+
+ <target name="NLog.ASPNet" depends="NLog">
+ <csc target="library" output="${output.dir}/NLog.ASPNet.dll" define="${nlog.define}" debug="${nlog.debug}">
+ <sources basedir="src/NLog.ASPNet">
+ <include name="**/*.cs" />
+ <include name="mscorlib.dll" />
+ <include name="System.dll" />
+ <include name="System.Xml.dll" />
+ </sources>
+ <references>
+ <include name="${output.dir}/NLog.dll" />
+ <include name="mscorlib.dll" />
+ <include name="System.dll" />
+ <include name="System.Xml.dll" />
+ </references>
+ </csc>
+ </target>
+
+ <target name="NLog.Win32" depends="NLog">
+ <csc target="library" output="${output.dir}/NLog.Win32.dll" define="${nlog.define}" debug="${nlog.debug}">
+ <sources basedir="src/NLog.Win32">
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${output.dir}/NLog.dll" />
+ </references>
+ </csc>
+ </target>
+
+ <target name="NLog.Test" depends="NLog">
+ <csc target="exe" output="${output.dir}/NLog.Test.exe" define="${nlog.define}" debug="${nlog.debug}">
+ <sources basedir="src/NLog.Test">
+ <include name="**/*.cs" />
+ </sources>
+ <references>
+ <include name="${output.dir}/NLog.dll" />
+ </references>
+ </csc>
+ <copy file="src/NLog.Test/App.config" tofile="${output.dir}/NLog.Test.exe.config" />
+ </target>
+
+ <target name="register-com" depends="configure">
+ <exec program="${path::combine(framework::get-framework-directory(framework::get-target-framework()),'regasm.exe')}"
+ commandline="/tlb ${output.dir}/NLog.ComInterop.dll" />
+ </target>
+
+ <target name="register-com-with-codebase" depends="configure">
+ <exec program="${path::combine(framework::get-framework-directory(framework::get-target-framework()),'regasm.exe')}"
+ commandline="/tlb /codebase ${output.dir}/NLog.ComInterop.dll" />
+ </target>
+
+ <target name="test" depends="NLog.Test">
+ <exec program="${output.dir}/NLog.Test.exe" />
+ </target>
+
+ <target name="webtest" depends="build">
+ <copy todir="webtest/bin">
+ <fileset basedir="${output.dir}">
+ <include name="*.dll" />
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="configure-net-1.0">
+ </target>
+
+ <target name="configure-net-1.1">
+ </target>
+
+ <target name="configure-netcf-1.0">
+ <property name="nlog.define" value="${nlog.define};NETCF;NETCF_1_0" />
+ </target>
+
+ <target name="build-net-1.0" depends="NLog, NLog.ASPNet, NLog.Win32, NLog.ComInterop" />
+ <target name="build-net-1.1" depends="NLog, NLog.ASPNet, NLog.Win32, NLog.ComInterop" />
+ <target name="build-netcf-1.0" depends="NLog, NLog.ComInterop" />
+
+ <target name="dist">
+ <exec program="nant.exe" commandline="-k:net-1.0 release package" if="${framework::exists('net-1.0')}" />
+ <exec program="nant.exe" commandline="-k:net-1.0 debug package" if="${framework::exists('net-1.0')}" />
+ <exec program="nant.exe" commandline="-k:net-1.1 release package" if="${framework::exists('net-1.1')}" />
+ <exec program="nant.exe" commandline="-k:net-1.1 debug package" if="${framework::exists('net-1.1')}" />
+ <exec program="nant.exe" commandline="-k:netcf-1.0 release package" if="${framework::exists('netcf-1.0')}" />
+ <exec program="nant.exe" commandline="-k:netcf-1.0 debug package" if="${framework::exists('netcf-1.0')}" />
+ </target>
+
+ <target name="updateversion">
+ <foreach item="Line" in="Nlog.version" delim=";" property="nlog.version">
+ <exec workingdir="${nant.project.basedir}" program="tools/ReplaceVersion.exe" commandline=". ${nlog.version}" />
+ </foreach>
+ </target>
+</project>
56 NLog.sln
@@ -0,0 +1,56 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog", "src\NLog\NLog.csproj", "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.ComInterop", "src\NLog.ComInterop\NLog.ComInterop.csproj", "{B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.ASPNet", "src\NLog.ASPNet\NLog.ASPNet.csproj", "{4BF1B19F-B459-4853-A8B6-B051C550D36E}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.Test", "src\NLog.Test\NLog.Test.csproj", "{5EC49108-97AE-40EA-B550-8960E4522718}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLog.Win32", "src\NLog.Win32\NLog.Win32.csproj", "{9BC14989-8F2D-48BB-A613-B63BB08492F3}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {020354EE-5073-4BB5-9AA2-A7EADA8CAD09}.Debug.ActiveCfg = Debug|.NET
+ {020354EE-5073-4BB5-9AA2-A7EADA8CAD09}.Debug.Build.0 = Debug|.NET
+ {020354EE-5073-4BB5-9AA2-A7EADA8CAD09}.Release.ActiveCfg = Release|.NET
+ {020354EE-5073-4BB5-9AA2-A7EADA8CAD09}.Release.Build.0 = Release|.NET
+ {B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}.Debug.ActiveCfg = Debug|.NET
+ {B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}.Debug.Build.0 = Debug|.NET
+ {B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}.Release.ActiveCfg = Release|.NET
+ {B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}.Release.Build.0 = Release|.NET
+ {4BF1B19F-B459-4853-A8B6-B051C550D36E}.Debug.ActiveCfg = Debug|.NET
+ {4BF1B19F-B459-4853-A8B6-B051C550D36E}.Debug.Build.0 = Debug|.NET
+ {4BF1B19F-B459-4853-A8B6-B051C550D36E}.Release.ActiveCfg = Release|.NET
+ {4BF1B19F-B459-4853-A8B6-B051C550D36E}.Release.Build.0 = Release|.NET
+ {5EC49108-97AE-40EA-B550-8960E4522718}.Debug.ActiveCfg = Debug|.NET
+ {5EC49108-97AE-40EA-B550-8960E4522718}.Debug.Build.0 = Debug|.NET
+ {5EC49108-97AE-40EA-B550-8960E4522718}.Release.ActiveCfg = Release|.NET
+ {5EC49108-97AE-40EA-B550-8960E4522718}.Release.Build.0 = Release|.NET
+ {9BC14989-8F2D-48BB-A613-B63BB08492F3}.Debug.ActiveCfg = Debug|.NET
+ {9BC14989-8F2D-48BB-A613-B63BB08492F3}.Debug.Build.0 = Debug|.NET
+ {9BC14989-8F2D-48BB-A613-B63BB08492F3}.Release.ActiveCfg = Release|.NET
+ {9BC14989-8F2D-48BB-A613-B63BB08492F3}.Release.Build.0 = Release|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+ GlobalSection(DPCodeReviewSolutionGUID) = preSolution
+ DPCodeReviewSolutionGUID = {C4811F53-E779-47F0-8C06-71551FBDB047}
+ EndGlobalSection
+EndGlobal
1  NLog.version
@@ -0,0 +1 @@
+0.2.0.0
132 doc/index.html
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//w3c//dtd xhtml 1.1 strict//en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>NLog - A .NET Logging Tool</title>
+ <link rel="stylesheet" type="text/css" href="style.css" />
+ <script src='prettyprint.js' type='text/javascript'></script>
+ </head>
+ <body onload="paintColors();">
+ <h3>What is NLog?</h3>
+ <p>
+ NLog is a simple logging library similar in concepts to <a href="http://log4net.sourceforge.net/">log4net</a>,
+ designed with simplicity and flexibility in mind.
+ </p>
+
+ <h3>Features</h3>
+ <ul>
+ <li>supports .NET, .NET Compact Framework and Mono 1.0</li>
+ <li>easy to configure, both with a config file and programmatically</li>
+ <li>easy to use - interface is identical to <code>Console.WriteLine</code></li>
+ </ul>
+ <h3>Usage</h3>
+ <p>Usage is simple. Just get an instance of a <code>Logger</code> and write your messages to it like you do with <code>Console.WriteLine()</code>.
+ There are 5 predefined logging levels. They are: <code>Debug, Info, Warn, Error, Fatal</code>.
+ <div class="table">
+ <table>
+ <col width="10%">
+ <col width="90%">
+ <tr>
+ <th>Log Level</td>
+ <th>Meaning</th>
+ </tr>
+ <tr>
+ <td>Debug</td>
+ <td>Messages useful for debugging, not normally enabled. This level can include high-traffic messages like the ones you write at each method call.</td>
+ </tr>
+ <tr>
+ <td>Info</td>
+ <td>Normal informational messages. Typically low traffic information - like "user logged on", "user authenticated".</td>
+ </tr>
+ <tr>
+ <td>Warn</td>
+ <td>Warning messages.</td>
+ </tr>
+ <tr>
+ <td>Error</td>
+ <td>Error messages.</td>
+ </tr>
+ <tr>
+ <td>Fatal</td>
+ <td>Fatal error messages. You usually write just one such message - just before the application terminates.</td>
+ </tr>
+ </table>
+ </div>
+ </p>
+ <h3>Example</h3>
+ <xmp class="code-csharp">
+using System;
+using System.Globalization;
+
+using NLog;
+
+class MyClass {
+ static Logger logger = LogManager.GetLogger("MyClass");
+
+ static void Main()
+ {
+ // you can use an interface known from log4net
+ logger.Debug("This is a debugging message");
+ logger.Info("This is a information message");
+ logger.Warn("This is a warning message");
+ logger.Error("This is an error");
+ logger.Fatal("This is a fatal error message");
+
+ // you can ask if the logging is enabled before writing
+ if (logger.IsDebugEnabled) {
+ logger.Debug("Some debug info");
+ }
+
+ // you can use WriteLine() style formatting
+ logger.Debug("The result is {0} {1}", 1 + 2, "zzz");
+
+ // you can even pass IFormatProvider for maximum flexibility
+ logger.Debug(CultureInfo.InvariantCulture, "The current time is {0}", DateTime.Now);
+
+ // you can ask if the logging is enabled for specified level
+ if (logger.IsEnabled(LogLevel.Warn)) {
+ // and you can write the message for a particular level, too
+ logger.Log(LogLevel.Warn, "Some warning info");
+ }
+ }
+}
+</xmp>
+ <h3>Log output</h3>
+ <p>By default, all log messages are displayed on standard output. NLog gives you the possibility
+ to change it. You create many log outputs and selectively route your messages to them.
+ The simplest way to do it is to create a configuration file section in your configuration file.
+ </p>
+ <p>
+ In the following example we define 4 log targets (appenders). Here are the logging rules:
+ <ol>
+ <li><code>Info, Warn</code> and <code>Error</code> messages are printed on the console.</li>
+ <li>All <code>Debug</code> messages go to <code>file1.log</code></li>
+ <li>All <code>Error</code> and <code>Fatal</code> messages go to <code>file2.log</code>. This is indicated by <code>minlevel</code> attribute.</li>
+ <li>All messages from loggers having SQL in their name go to <code>file3.log</code>.</li>
+ </ol>
+ </p>
+<xmp class="code-xml">
+<?xml version="1.0" ?>
+<configuration>
+ <configSections>
+ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
+ </configSections>
+
+ <nlog>
+ <appenders>
+ <appender name="console" type="Console" />
+ <appender name="file1" type="File" filename="file1.log" />
+ <appender name="file2" type="File" filename="file2.log" />
+ <appender name="file3" type="File" filename="file3.log" />
+ </appenders>
+
+ <rules>
+ <logger name="*" levels="Info,Warn,Error" appendTo="console" />
+ <logger name="*" level="Debug" appendTo="file1" />
+ <logger name="*" minlevel="Error" appendTo="file2" />
+ <logger name="*SQL*" appendTo="file3" />
+ </rules>
+ </nlog>
+</configuration></xmp>
+ </body>
+</html>
121 doc/prettyprint.js
@@ -0,0 +1,121 @@
+var keywords = "";
+
+var keywordArray = new Array (
+ "abstract","event","new","struct","as","explicit","null","switch","base","extern",
+ "object","this","bool","false","operator","throw","break","finally","out","true",
+ "byte","fixed","override","try","case","float","params","typeof","catch","for",
+ "private","uint","char","foreach","protected","ulong","checked","goto","public",
+ "unchecked","class","if","readonly","unsafe","const","implicit","ref","ushort",
+ "continue","in","return","using","decimal","int","sbyte","virtual","default",
+ "interface","sealed","volatile","delegate","internal","short","void","do","is",
+ "sizeof","while","double","lock","stackalloc","else","long","static","enum",
+ "namespace","string");
+
+
+function paintColors ()
+{
+ keywords = "(";
+ for (n=0; n<keywordArray.length; n++)
+ keywords += "\\b" + keywordArray[n] + "\\b|";
+ keywords += "string)";
+
+ var elems = document.getElementsByTagName ("xmp");
+ for (n=elems.length - 1; n>=0; n--)
+ {
+ if (elems[n].className == "code-csharp") {
+ format (elems [n], formatCs);
+ }
+ else if (elems[n].className == "code-xml") {
+ format (elems [n], formatXml);
+ }
+ }
+}
+
+function format (node, func)
+{
+ text = node.innerHTML;
+
+ div = document.createElement("div");
+ var className = node.className;
+
+ // remove trailing/leading lines
+ while (text.charAt (0) == "\n" || text.charAt (0) == "\r" )
+ text = text.substr (1);
+
+ while (text.charAt (text.length) == "\n" || text.charAt (text.length) == "\r" )
+ text = text.splice (0, -1);
+
+ div.innerHTML = func (text);
+ node.parentNode.replaceChild(div, node);
+ div.className = className;
+}
+
+function formatCs (text)
+{
+
+ var re = / /g;
+ text = text.replace (re, "&nbsp;");
+
+ re = /<(.*?)>/g;
+ text = text.replace (re, "<___span style='color:red'_!_$1___/span_!_>");
+
+ re = /</g;
+ text = text.replace (re, "&lt;");
+
+ re = />/g;
+ text = text.replace (re, "&gt;");
+
+ re = /___/g;
+ text = text.replace (re, "<");
+
+ re = /_!_/g;
+ text = text.replace (re, ">");
+
+ // cant get this one to work in the good syntax
+ re = new RegExp ("\"((((?!\").)|\\\")*?)\"","g");
+ text = text.replace (re,"<span style='color:purple'>\"$1\"</span>");
+
+ re = /\/\/(((.(?!\"\<\/span\>))|"(((?!").)*)"\<\/span\>)*)(\r|\n|\r\n)/g;
+ text = text.replace (re,"<span style='color:green'>//$1</span><br/>");
+
+ re = new RegExp (keywords,"g");
+ text = text.replace (re,"<span style='color:blue'>$1</span>");
+
+ re = /\t/g;
+ text = text.replace (re,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+
+ re = /\n/g;
+ text = text.replace (re,"<br/>");
+
+ div = document.createElement("div");
+ div.innerHTML = text;
+
+ spans = div.getElementsByTagName ("span")
+ for (i = 0; i < spans.length; i++) {
+ if (spans [i].parentNode.nodeName == "SPAN") {
+ spans [i].style.color = "";
+ }
+ }
+
+ return div.innerHTML;
+}
+
+function formatXml (text)
+{
+ var re = / /g;
+ text = text.replace (re, "&nbsp;");
+
+ re = /\t/g;
+ text = text.replace (re, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+
+ re = /\<\s*(\/?)\s*(.*?)\s*(\/?)\s*\>/g;
+ text = text.replace (re,"<span style='color:blue'>&lt;$1</span><span style='color:maroon'>$2</span><span style='color:blue'>$3&gt;</span>");
+
+ re = /"(.*?)"/g;
+ text = text.replace (re,"\"<span style='color:purple'>$1</span>\"");
+
+ re = /\r\n|\r|\n/g;
+ text = text.replace (re, "<br/>");
+
+ return text;
+}
82 doc/style.css
@@ -0,0 +1,82 @@
+body
+{
+ font-family: Verdana;
+ font-size: 80%;
+ background-color: #ffffff;
+}
+
+h3
+{
+ font-weight: bold;
+ color: #000080;
+ font-size: 120%;
+}
+
+code
+{
+ font-size: 12px;
+ color: #0000c0;
+}
+
+pre.code
+{
+ background-color: #fffff0;
+ border: 1px solid #808080;
+ margin-left: 20px;
+ padding: 4px;
+ font-size: 12px;
+ color: #202020;
+}
+
+.code, .xml , .script
+{
+ margin:15px;
+ padding:15px;
+ font-size: small;
+ font-family: "Courier New", Courier;
+ background:whitesmoke;
+ border: solid 1px silver;
+ line-height:110%;
+}
+.code-xml, .code-csharp
+{
+ margin:15px;
+ padding:15px;
+ font-size: small;
+ font-family: "Courier New", Courier;
+ background:whitesmoke;
+ border: solid 1px silver;
+ line-height:110%;
+}
+
+div.table {
+ margin-left: 40px;
+ font-family: Verdana, Arial, Helvetica, Geneva, SunSans-Regular, sans-serif;
+}
+
+.table table {
+ font-size: 100%;
+ border-collapse: collapse;
+ width: 93%;
+}
+
+.table th {
+ background-color: #eeeeee;
+ color: #000080;
+ font-weight: bolder;
+ padding: 5px;
+ border: 1px solid #999999;
+ text-align: left;
+}
+
+.table td {
+ border: 1px solid #999999;
+ padding: 5px;
+}
+
+.table td.section {
+ border: 1px solid #999999;
+ background-color: #f0f0e0;
+ padding: 5px;
+ font-weight: bold;
+}
55 src/NLog.ASPNet/Appenders/ASPNetTraceAppender.cs
@@ -0,0 +1,55 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Web;
+
+namespace NLog.ASPNet.Appenders
+{
+ public class ASPNetTraceAppender : NLog.Appender
+ {
+ public override void Append(LogEventInfo ev) {
+ HttpContext context = HttpContext.Current;
+
+ if (context == null) {
+ return;
+ }
+
+ if (ev.Level >= LogLevel.Warn) {
+ context.Trace.Warn(CompiledLayout.GetFormattedMessage(ev));
+ } else {
+ context.Trace.Write(CompiledLayout.GetFormattedMessage(ev));
+ }
+ }
+ }
+}
45 src/NLog.ASPNet/AssemblyInfo.cs
@@ -0,0 +1,45 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyTitle("NLog.ASPNet")]
+[assembly: AssemblyDescription("NLog - ASP.NET logging support")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("NLog")]
+[assembly: AssemblyProduct("NLog - .NET Logging Library")]
+[assembly: AssemblyCopyright("Copyright (c) 2004 by Jaroslaw Kowalski")]
+[assembly: AssemblyCulture("")]
+
+[assembly: AssemblyVersion("0.2.0.0")]
40 src/NLog.ASPNet/AssemblySign.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System.Reflection;
+
+#if NANT
+[assembly: AssemblyKeyFile("src/NLog.snk")]
+#else
+[assembly: AssemblyKeyFile("../../../NLog.snk")]
+#endif
61 src/NLog.ASPNet/LayoutAppenders/ASPNetRawUrlLayoutAppender.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Text;
+using System.Web;
+
+namespace NLog.LayoutAppenders
+{
+ [LayoutAppender("aspnet-rawurl")]
+ public class RawUrlLayoutAppender : LayoutAppender
+ {
+ public override int GetEstimatedBufferSize(LogEventInfo ev)
+ {
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ return 0;
+
+ return context.Request.RawUrl.Length;
+ }
+
+ public override void Append(StringBuilder builder, LogEventInfo ev)
+ {
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ return;
+
+ builder.Append(context.Request.RawUrl);
+ }
+ }
+}
65 src/NLog.ASPNet/LayoutAppenders/ASPNetSessionValueLayoutAppender.cs
@@ -0,0 +1,65 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Text;
+using System.Web;
+
+namespace NLog.LayoutAppenders
+{
+ [LayoutAppender("aspnet-session")]
+ public class ASPNETSessioValueLayoutAppender : LayoutAppender
+ {
+ private string _parameter = null;
+
+ public override int GetEstimatedBufferSize(LogEventInfo ev)
+ {
+ if (_parameter == null)
+ return 0;
+ else
+ return 64;
+ }
+
+ public override void Append(StringBuilder builder, LogEventInfo ev)
+ {
+ if (_parameter == null)
+ return;
+
+ HttpContext context = HttpContext.Current;
+ if (context == null)
+ return;
+
+ builder.Append(context.Session[_parameter]);
+ }
+ }
+}
120 src/NLog.ASPNet/NLog.ASPNet.csproj
@@ -0,0 +1,120 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{4BF1B19F-B459-4853-A8B6-B051C550D36E}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "NLog.ASPNet"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "NLog.ASPNet"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System.Web"
+ AssemblyName = "System.Web"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Web.dll"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ <Reference
+ Name = "NLog"
+ Project = "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "AssemblySign.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Appenders\ASPNetTraceAppender.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "LayoutAppenders\ASPNetRawUrlLayoutAppender.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "LayoutAppenders\ASPNetSessionValueLayoutAppender.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
45 src/NLog.ComInterop/AssemblyInfo.cs
@@ -0,0 +1,45 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyTitle("NLog.ComInterop")]
+[assembly: AssemblyDescription("NLog COM Interop")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("NLog")]
+[assembly: AssemblyProduct("NLog - .NET Logging Library")]
+[assembly: AssemblyCopyright("Copyright (c) 2004 by Jaroslaw Kowalski")]
+[assembly: AssemblyCulture("")]
+
+[assembly: AssemblyVersion("0.2.0.0")]
40 src/NLog.ComInterop/AssemblySign.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System.Reflection;
+
+#if NANT
+[assembly: AssemblyKeyFile("src/NLog.snk")]
+#else
+[assembly: AssemblyKeyFile("../../../NLog.snk")]
+#endif
54 src/NLog.ComInterop/ILogger.cs
@@ -0,0 +1,54 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+
+namespace NLog.ComInterop
+{
+ public interface ILogger
+ {
+ void Log(string level, string message);
+ void Debug(string message);
+ void Info(string message);
+ void Warn(string message);
+ void Error(string message);
+ void Fatal(string message);
+
+ bool IsEnabled(string level);
+ bool IsDebugEnabled { get; }
+ bool IsInfoEnabled { get; }
+ bool IsWarnEnabled { get; }
+ bool IsErrorEnabled { get; }
+ bool IsFatalEnabled { get; }
+ }
+}
128 src/NLog.ComInterop/Logger.cs
@@ -0,0 +1,128 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+
+using NLog;
+
+namespace NLog.ComInterop
+{
+ public class Logger : ILogger
+ {
+ private static NLog.Logger _defaultLogger = new NullLogger();
+
+ private NLog.Logger _logger = _defaultLogger;
+ private string _loggerName = String.Empty;
+
+ public void Log(string level, string message) {
+ _logger.Log(StringToLevel(level), message);
+ }
+
+ public void Debug(string message) {
+ _logger.Debug(message);
+ }
+
+ public void Info(string message) {
+ _logger.Info(message);
+ }
+
+ public void Warn(string message) {
+ _logger.Warn(message);
+ }
+
+ public void Error(string message) {
+ _logger.Error(message);
+ }
+
+ public void Fatal(string message) {
+ _logger.Fatal(message);
+ }
+
+ public bool IsEnabled(string level)
+ {
+ return _logger.IsEnabled(StringToLevel(level));
+ }
+
+ public bool IsDebugEnabled
+ {
+ get { return _logger.IsDebugEnabled; }
+ }
+
+ public bool IsInfoEnabled
+ {
+ get { return _logger.IsInfoEnabled; }
+ }
+
+ public bool IsWarnEnabled
+ {
+ get { return _logger.IsWarnEnabled; }
+ }
+
+ public bool IsErrorEnabled
+ {
+ get { return _logger.IsErrorEnabled; }
+ }
+
+ public bool IsFatalEnabled
+ {
+ get { return _logger.IsFatalEnabled; }
+ }
+
+ public string LoggerName
+ {
+ get { return _loggerName; }
+ set {
+ _loggerName = value;
+ _logger = NLog.LogManager.GetLogger(value);
+ }
+ }
+
+ private static LogLevel StringToLevel(string s) {
+ switch (s[0]) {
+ case 'D':
+ return LogLevel.Debug;
+ case 'I':
+ return LogLevel.Info;
+ case 'W':
+ return LogLevel.Warn;
+ case 'E':
+ return LogLevel.Error;
+ case 'F':
+ return LogLevel.Fatal;
+
+ default:
+ throw new NotSupportedException("LogLevel not supported: " + s);
+ }
+ }
+ }
+}
110 src/NLog.ComInterop/NLog.ComInterop.csproj
@@ -0,0 +1,110 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{B3F8E5FB-C9D4-4C12-841F-8009EB60DB3D}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "NLog.ComInterop"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "NLog.ComInterop"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ <Reference
+ Name = "NLog"
+ Project = "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "AssemblySign.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ILogger.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Logger.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
19 src/NLog.Test/App.config
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="windows-1250" ?>
+<configuration>
+ <configSections>
+ <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
+ </configSections>
+ <nlog>
+ <appenders>
+ <appender name="console" type="Console" layout="${machinename}" />
+ <appender name="null" type="Null" layout="${date:format=yyyy-MM-dd}|${callsite:filename=true}|${message}" formatMessage="true" />
+ <appender name="null2" type="Null" layout="${date:format=yyyy-MM-dd}|${callsite}|${message}" formatMessage="true" />
+ <appender name="null3" type="Null" layout="${date:format=yyyy-MM-dd}|${message}" formatMessage="true" />
+ <appender name="file" type="File" layout="${date:format=yyyy-MM-dd}|${callsite:filename=true}|${message}" createDirs="true" />
+ </appenders>
+
+ <rules>
+ <logger name="*" level="Debug" appendTo="console" />
+ </rules>
+ </nlog>
+</configuration>
94 src/NLog.Test/NLog.Test.csproj
@@ -0,0 +1,94 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{5EC49108-97AE-40EA-B550-8960E4522718}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "NLog.Test"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "NLog.Test"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "NLog"
+ Project = "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "NLog.ASPNet"
+ Project = "{4BF1B19F-B459-4853-A8B6-B051C550D36E}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "App.config"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "Test.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
72 src/NLog.Test/Test.cs
@@ -0,0 +1,72 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Security.Principal;
+
+using NLog;
+using NLog.Config;
+
+class Test {
+ static void Main(string[] args) {
+ int repeat = 3;
+
+ AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
+
+ if (args.Length > 0)
+ {
+ repeat = Int32.Parse(args[0]);
+ }
+
+ DateTime dt0 = DateTime.Now;
+ for (int i = 0; i < repeat; ++i)
+ {
+ NLog.Logger l = NLog.LogManager.GetLogger("Aaa");
+ NLog.Logger l2 = NLog.LogManager.GetLogger("Bbb");
+
+ l.Debug("to jest debug");
+ l.Info("to jest info");
+ l.Warn("to jest warning");
+ l2.Debug("to jest debug");
+ l2.Info("to jest info");
+ l2.Warn("to jest warning");
+ l.Error("to jest error");
+ l.Fatal("to jest fatal");
+ l2.Error("to jest error");
+ l2.Fatal("to jest fatal");
+ }
+
+ DateTime dt1 = DateTime.Now;
+ Console.WriteLine(dt1 - dt0);
+ }
+}
107 src/NLog.Win32/LayoutAppenders/Registry.cs
@@ -0,0 +1,107 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Text;
+using System.IO;
+
+using Microsoft.Win32;
+
+namespace NLog.Win32.LayoutAppenders
+{
+ [LayoutAppender("registry")]
+ public class RegistryLayoutAppender : LayoutAppender
+ {
+ private string _value = null;
+ private string _defaultValue = null;
+ private string _key = null;
+ private RegistryKey _rootKey = Registry.LocalMachine;
+ private string _subKey = null;
+
+ public string Value
+ {
+ get { return _value; }
+ set { _value = value; }
+ }
+
+ public string DefaultValue
+ {
+ get { return _defaultValue; }
+ set { _defaultValue = value; }
+ }
+
+ public string Key
+ {
+ get { return _key; }
+ set
+ {
+ _key = value;
+ int pos = _key.IndexOfAny(new char[] { '\\','/' });
+ if (pos >= 0) {
+ string root = _key.Substring(0, pos);
+ switch (root.ToUpper())
+ {
+ case "HKEY_LOCAL_MACHINE":
+ case "HKLM":
+ _rootKey = Registry.LocalMachine;
+ break;
+
+ case "HKEY_CURRENT_USER":
+ case "HKCU":
+ _rootKey = Registry.CurrentUser;
+ break;
+
+ default:
+ throw new ArgumentException("Key name is invalid. Root hive not recognized.");
+ }
+ _subKey = _key.Substring(pos + 1).Replace('/', '\\');
+ } else {
+ throw new ArgumentException("Key name is invalid");
+ }
+ }
+ }
+
+ public override int GetEstimatedBufferSize(LogEventInfo ev)
+ {
+ return 32;
+ }
+
+ public override void Append(StringBuilder builder, LogEventInfo ev)
+ {
+ using (RegistryKey key = _rootKey.OpenSubKey(_subKey))
+ {
+ builder.Append(key.GetValue(Value, DefaultValue));
+ }
+ }
+ }
+}
95 src/NLog.Win32/NLog.Win32.csproj
@@ -0,0 +1,95 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{9BC14989-8F2D-48BB-A613-B63BB08492F3}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "NLog.Win32"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "NLog.Win32"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "NLog"
+ Project = "{020354EE-5073-4BB5-9AA2-A7EADA8CAD09}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.XML"
+ HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "LayoutAppenders\Registry.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
BIN  src/NLog.snk
Binary file not shown
92 src/NLog/Appender.cs
@@ -0,0 +1,92 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Text;
+
+namespace NLog
+{
+ public abstract class Appender
+ {
+ const string InternalAppenderNamePrefix = "NLog.Appenders.";
+ const string InternalAppenderNameSuffix = "Appender";
+
+ protected Appender()
+ {
+ Layout = "${longdate}|${level:uppercase=true}|${logger}|${message}";
+ }
+
+ private Layout _compiledlayout;
+ private string _name;
+
+ public string Name
+ {
+ get { return _name; }
+ set { _name = value; }
+ }
+
+ public string Layout
+ {
+ get { return _compiledlayout.Text; }
+ set { _compiledlayout = new Layout(value); }
+ }
+
+ public Layout CompiledLayout
+ {
+ get { return _compiledlayout; }
+ set { _compiledlayout = value; }
+ }
+
+ public abstract void Append(LogEventInfo ev);
+
+ public static Appender Create(string name) {
+ Type appenderType;
+
+ if (name.IndexOf('.') < 0 && name.IndexOf(',') < 0) {
+ // simple name - no dot nor comma - we create an internal appender
+ string fullName = InternalAppenderNamePrefix + name + InternalAppenderNameSuffix;
+
+ // get the type ignoring case and throw on error
+ appenderType = typeof(Appender).Assembly.GetType(fullName, true);
+ } else {
+ appenderType = Type.GetType(name);
+ }
+ return (Appender)Activator.CreateInstance(appenderType);
+ }
+
+ public virtual int NeedsStackTrace()
+ {
+ return CompiledLayout.NeedsStackTrace();
+ }
+ }
+}
44 src/NLog/Appenders/ConsoleAppender.cs
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+
+namespace NLog.Appenders
+{
+ public class ConsoleAppender : NLog.Appender
+ {
+ public override void Append(LogEventInfo ev) {
+ Console.WriteLine(CompiledLayout.GetFormattedMessage(ev));
+ }
+ }
+}
161 src/NLog/Appenders/FileAppender.cs
@@ -0,0 +1,161 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Xml;
+using System.IO;
+
+using NLog;
+
+namespace NLog.Appenders
+{
+ public class FileAppender : NLog.Appender
+ {
+ private Random _random = new Random();
+ private Layout _fileNameLayout;
+ private bool _createDirs = false;
+ private bool _keepFileOpen = true;
+ private string _lastFileName = String.Empty;
+ private StreamWriter _outputFile;
+ private System.Text.Encoding _encoding = System.Text.Encoding.Default;
+ private bool _autoFlush = true;
+ private bool _concurrentWrites = true;
+ private int _concurrentWriteAttempts = 10;
+ private int _concurrentWriteAttemptDelay = 1;
+
+ public string FileName
+ {
+ get { return _fileNameLayout.Text; }
+ set { _fileNameLayout = new Layout(value); }
+ }
+
+ public bool CreateDirs
+ {
+ get { return _createDirs; }
+ set { _createDirs = value; }
+ }
+
+ public bool KeepFileOpen
+ {
+ get { return _keepFileOpen; }
+ set { _keepFileOpen = value; }
+ }
+
+ public bool AutoFlush
+ {
+ get { return _autoFlush; }
+ set { _autoFlush = value; }
+ }
+
+ public string Encoding
+ {
+ get { return _encoding.WebName; }
+ set { _encoding = System.Text.Encoding.GetEncoding(value); }
+ }
+
+ public bool ConcurrentWrites
+ {
+ get { return _concurrentWrites; }
+ set { _concurrentWrites = value; }
+ }
+
+ public int ConcurrentWriteAttempts
+ {
+ get { return _concurrentWriteAttempts; }
+ set { _concurrentWriteAttempts = value; }
+ }
+
+ public int ConcurrentWriteAttemptDelay
+ {
+ get { return _concurrentWriteAttemptDelay; }
+ set { _concurrentWriteAttemptDelay = value; }
+ }
+
+ private StreamWriter OpenStreamWriter(string fileName) {
+ StreamWriter retVal;
+
+ FileInfo fi = new FileInfo(fileName);
+ if (!fi.Exists)
+ {
+ if (!fi.Directory.Exists)
+ {
+ Directory.CreateDirectory(fi.DirectoryName);
+ }
+ }
+
+ if (!ConcurrentWrites) {
+ retVal = new StreamWriter(fileName, true, _encoding);
+ } else {
+ int currentDelay = _concurrentWriteAttemptDelay;
+ retVal = null;
+
+ for (int i = 0; i < _concurrentWriteAttempts; ++i) {
+ try {
+ retVal = new StreamWriter(fileName, true, _encoding);
+ break;
+ }
+ catch (IOException)
+ {
+ int actualDelay = _random.Next(currentDelay);
+ currentDelay *= 2;
+ System.Threading.Thread.Sleep(actualDelay);
+ }
+ }
+ return null;
+ }
+
+ retVal.AutoFlush = _autoFlush;
+ return retVal;
+ }
+
+ public override void Append(LogEventInfo ev) {
+ string fileName = _fileNameLayout.GetFormattedMessage(ev);
+
+ if (fileName != _lastFileName && _outputFile != null) {
+ _outputFile.Close();
+ _outputFile = null;
+ }
+ _lastFileName = fileName;
+ if (_outputFile == null) {
+ _outputFile = OpenStreamWriter(fileName);
+ if (_outputFile == null)
+ return;
+ }
+ _outputFile.WriteLine(CompiledLayout.GetFormattedMessage(ev));
+ if (!KeepFileOpen || ConcurrentWrites) {
+ _outputFile.Close();
+ _outputFile = null;
+ }
+ }
+ }
+}
54 src/NLog/Appenders/MemoryAppender.cs
@@ -0,0 +1,54 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Diagnostics;
+
+namespace NLog.Appenders
+{
+ public class MemoryAppender : NLog.Appender
+ {
+ private ArrayList _logs = new ArrayList();
+
+ public override void Append(LogEventInfo ev) {
+ _logs.Add(CompiledLayout.GetFormattedMessage(ev));
+ }
+
+ public ArrayList Logs
+ {
+ get { return _logs; }
+ }
+ }
+}
59 src/NLog/Appenders/NullAppender.cs
@@ -0,0 +1,59 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Diagnostics;
+
+namespace NLog.Appenders
+{
+ public class NullAppender : NLog.Appender
+ {
+ private bool _formatMessage = false;
+
+ public bool FormatMessage
+ {
+ get { return _formatMessage; }
+ set { _formatMessage = value; }
+ }
+
+ public override void Append(LogEventInfo ev)
+ {
+ if (_formatMessage)
+ {
+ CompiledLayout.GetFormattedMessage(ev);
+ }
+ }
+ }
+}
51 src/NLog/Appenders/TraceAppender.cs
@@ -0,0 +1,51 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+#if !NETCF
+using System;
+using System.Diagnostics;
+
+namespace NLog.Appenders
+{
+ public class TraceAppender : NLog.Appender
+ {
+ public override void Append(LogEventInfo ev) {
+ if (ev.Level >= LogLevel.Error) {
+ Trace.Fail(CompiledLayout.GetFormattedMessage(ev));
+ } else {
+ Trace.WriteLine(CompiledLayout.GetFormattedMessage(ev));
+ }
+ }
+ }
+}
+#endif
56 src/NLog/AssemblyInfo.cs
@@ -0,0 +1,56 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+
+[assembly: AssemblyTitle("NLog")]
+[assembly: AssemblyDescription("NLog")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("NLog")]
+[assembly: AssemblyProduct("NLog - .NET Logging Library")]
+[assembly: AssemblyCopyright("Copyright (c) 2004 by Jaroslaw Kowalski")]
+[assembly: AssemblyCulture("")]
+
+[assembly: AssemblyVersion("0.2.0.0")]
+
+[assembly: CLSCompliant(true)]
+[assembly: ComVisible(false)]
+
+#if !NETCF
+[assembly: ReflectionPermission(SecurityAction.RequestMinimum, Unrestricted=true)]
+[assembly: SecurityPermission(SecurityAction.RequestMinimum, Flags=SecurityPermissionFlag.Execution)]
+#endif
40 src/NLog/AssemblySign.cs
@@ -0,0 +1,40 @@
+//
+// Copyright (c) 2004 Jaroslaw Kowalski <jaak@polbox.com>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of the Jaroslaw Kowalski nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE