This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from theLosers106/master
Upgrade to version 1.2.1.0
- Loading branch information
Showing
19 changed files
with
31,356 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using log4net; | ||
using log4net.Repository.Hierarchy; | ||
using log4net.Core; | ||
using log4net.Appender; | ||
using log4net.Layout; | ||
|
||
namespace NiceHashMiner | ||
{ | ||
public class Logger | ||
{ | ||
public static readonly ILog log = LogManager.GetLogger(typeof(Logger)); | ||
|
||
public static void ConfigureWithFile() | ||
{ | ||
Hierarchy h = (Hierarchy)LogManager.GetRepository(); | ||
|
||
if (Config.ConfigData.LogLevel == 1) | ||
h.Root.Level = Level.Info; | ||
else if (Config.ConfigData.LogLevel == 2) | ||
h.Root.Level = Level.Warn; | ||
else if (Config.ConfigData.LogLevel == 3) | ||
h.Root.Level = Level.Error; | ||
|
||
h.Root.AddAppender(CreateFileAppender()); | ||
h.Configured = true; | ||
} | ||
|
||
public static IAppender CreateFileAppender() | ||
{ | ||
RollingFileAppender appender = new RollingFileAppender(); | ||
appender.Name = "RollingFileAppender"; | ||
appender.File = "log.txt"; | ||
appender.AppendToFile = true; | ||
appender.RollingStyle = RollingFileAppender.RollingMode.Size; | ||
appender.MaxSizeRollBackups = 1; | ||
appender.MaxFileSize = Config.ConfigData.LogMaxFileSize; | ||
appender.PreserveLogFileNameExtension = true; | ||
|
||
PatternLayout layout = new PatternLayout(); | ||
layout.ConversionPattern = "[%date{yyyy-MM-dd HH:mm:ss}] [%level] %message%newline"; | ||
layout.ActivateOptions(); | ||
|
||
appender.Layout = layout; | ||
appender.ActivateOptions(); | ||
|
||
return appender; | ||
} | ||
} | ||
} |
Oops, something went wrong.