Change log facility.

This commit is contained in:
qianlifeng
2015-01-20 22:33:45 +08:00
parent 3f6cb3cd73
commit 1ef163f827
26 changed files with 2746 additions and 135 deletions

View File

@@ -1,41 +1,41 @@
using System;
using System.Reflection;
using log4net;
using NLog;
namespace Wox.Infrastructure.Logger
{
public class Log
{
private static ILog fileLogger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static NLog.Logger logger = LogManager.GetCurrentClassLogger();
public static void Error(string msg)
{
fileLogger.Error(msg);
logger.Error(msg);
}
public static void Error(Exception e)
{
fileLogger.Error(e.Message + "\r\n" + e.StackTrace);
logger.Error(e.Message + "\r\n" + e.StackTrace);
}
public static void Debug(string msg)
{
fileLogger.Debug(msg);
logger.Debug(msg);
}
public static void Info(string msg)
{
fileLogger.Info(msg);
logger.Info(msg);
}
public static void Warn(string msg)
{
fileLogger.Warn(msg);
logger.Warn(msg);
}
public static void Fatal(string msg)
{
fileLogger.Fatal(msg);
logger.Fatal(msg);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
You can use http://www.legitlog.com/ to visualize those logs
-->
<!-- log level
Trace - very detailed logs, which may include high-volume information such as protocol payloads. This log level is typically only enabled during development
Debug - debugging information, less detailed than trace, typically not enabled in production environment.
Info - information messages, which are normally enabled in production environment
Warn - warning messages, typically for non-critical issues, which can be recovered or which are temporary failures
Error - error messages
Fatal - very serious errors-->
<targets>
<target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}.log"/>
<target xsi:type="Console" name="console" />
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="file" />
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</nlog>

View File

@@ -33,5 +33,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -37,15 +37,14 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.3.2.0.0\lib\net35\NLog.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
@@ -84,6 +83,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Logger\NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net35" />
<package id="NLog" version="3.2.0.0" targetFramework="net35" />
</packages>