Просмотр исходного кода

NLog.config配置可以输出文件名和行号了

tanghai 14 лет назад
Родитель
Сommit
f0bd1190bc

+ 3 - 1
CSharp/Editor/Editor.csproj

@@ -99,7 +99,9 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="NLog.config" />
+    <None Include="NLog.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
     <None Include="Packages.config" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 1 - 1
CSharp/Editor/NLog.config

@@ -3,7 +3,7 @@
 		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<targets>
 		<target name="file" xsi:type="File" fileName="${basedir}/Log.txt"
-				layout="${date:format=HH\:mm\:ss}|${threadid:padCharacter=0:padding=4:fixedLength=true}|${message}"/>
+				layout="${longdate} ${threadid:padCharacter=0:padding=4:fixedLength=true} ${callsite:className=false:includeSourcePath=false:methodName=false:fileName=true}] ${message}"/>
 	</targets>
 	<rules>
 		<logger name="*" minlevel="Trace" writeTo="file"/>

+ 1 - 1
CSharp/Modules/LoginModule/Login.csproj

@@ -50,7 +50,7 @@
       <HintPath>..\..\Packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
     </Reference>
     <Reference Include="NLog">
-      <HintPath>..\..\Packages\NLog.2.0.0.0\lib\NET40\NLog.dll</HintPath>
+      <HintPath>..\..\Packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.Composition" />

+ 3 - 0
CSharp/Modules/LoginModule/LoginViewModel.cs

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
 using System.Net.Sockets;
 using System.Security.Cryptography;
 using System;
+using NLog;
 
 namespace Module.Login
 {
@@ -116,6 +117,8 @@ namespace Module.Login
 			await stream.WriteAsync(passMD5Buffer, 0, passMD5Buffer.Length);
 
 			LogInfo += "username: " + username.Trim() + " password md5: " + passMD5 + Environment.NewLine;
+			Logger logger = LogManager.GetCurrentClassLogger();
+			logger.Debug("11111111111");
 		}
 	}
 }