本文整理汇总了C#中Log.Error方法的典型用法代码示例。如果您正苦于以下问题:C# Log.Error方法的具体用法?C# Log.Error怎么用?C# Log.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log.Error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parseUnSignedNumber
/// <summary>
/// Parses unsigned constant values. Parses hex, oct, bin and exponent values as well.
/// </summary>
/// <param name="val">The string value to convert from. It can be hex, oct, bin, or nnnExx</param>
/// <param name="maxBitSize"></param>
/// <param name="paramNo">The parameter place for logging errors. </param>
/// <param name="log"></param>
/// <returns></returns>
internal static uint parseUnSignedNumber(string val, int maxBitSize, int paramNo, Log log)
{
Match m = Regex.Match(val, RegexRecognizers.UnSignedNumber);
if (!m.Groups[2].Success)
{
log.Error("param {0}: unable to recognize constant '{1}'", paramNo, val);
return 0;
}
char opType = m.Groups[1].Value[0];
string opVal = m.Groups[2].Value;
if (opVal == "")
log.Error("param {0}: compiler error 4360 '{1}'", paramNo, val);
uint num;
if (opType > '0' && opType <= '9')
num = UInt32.Parse(opVal, NumberStyles.AllowLeadingSign | NumberStyles.AllowExponent);
else // if (opType == 'x' || opType == 'o' || opType == 'b')
num = Convert.ToUInt32(opVal, (opType == 'x') ? 16 : (opType == 'o') ? 8 : 2);
if (num > ((1 << maxBitSize) - 1))
{
log.Error("param {0}: The value '{1}' will not fit in {2} bits", paramNo, val, maxBitSize);
num &= (uint)((1 << maxBitSize) - 1);
}
return num;
}
示例2: Main
static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
var log = new Log();
log.Info("Startup");
var servers = new List<ServerInfo>();
using (var dc = new Arma3BeClientContext())
{
servers = dc.ServerInfo.Where(x => x.Active).ToList();
}
var models = servers.Select(x=>OpenServerInfo(x, log)).ToList();
while (true)
{
try
{
var t = Task.Run(() => run(models));
t.Wait();
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例3: AboutWindow
public static Window AboutWindow(Application application, Log log)
{
const string prefix = "Dialogs - AboutWindow";
if ((application == null) || application.HasExited)
{
throw new RegressionTestFailedException(prefix + ": Application does not exist or has already exited.");
}
// Note that the windows can't be found through an Automation ID for some reason, hence
// using the title of the window.
var mainWindow = MainWindow(application, log);
if (mainWindow == null)
{
return null;
}
return Retry.Times(
() =>
{
log.Debug(prefix, "Trying to get the about window.");
var window = mainWindow.ModalWindow("About");
if (window == null)
{
log.Error(prefix, "Failed to get the about window.");
}
return window;
});
}
示例4: Main
public static void Main(string[] args)
{
Configuration config = Configuration.LoadConfiguration("settings.json");
Log mainLog = new Log (config.MainLog, null);
//byte counter = 0;
foreach (Configuration.BotInfo info in config.Bots)
{
//Console.WriteLine("--Launching bot " + info.DisplayName +"--");
mainLog.Info ("Launching Bot " + info.DisplayName + "...");
new Thread(() =>
{
int crashes = 0;
while (crashes < 1000)
{
try
{
new Bot(info, config.ApiKey);
}
catch (Exception e)
{
mainLog.Error ("Error With Bot: "+e);
crashes++;
}
}
}).Start();
Thread.Sleep(5000);
}
}
示例5: CreateTable
/// <summary>
/// Create a table
/// e.g. DDL.CreateTable( "Sample", "col1,int,col2,int,col3,varchar(10),col4,int,col5,int");
/// </summary>
/// <param name="sTableName"></param> - Name of the new table
/// <param name="sColumns_i"></param> - A string containing list of colums in the format Column1,datatype,
/// Column2,datatype...etc
public static void CreateTable(string sTableName, string sColumns_i)
{
using (Log log = new Log(".::()"))
{
try
{
string sQuerry = "CREATE TABLE " + sTableName + "(";
string[] sColums = Strings.Split(sColumns_i, ",", -1, CompareMethod.Text);
sQuerry = sQuerry + sColums[0] + " " + sColums[1];
for (int nIndex = 2; nIndex < sColums.Length; nIndex += 2)
sQuerry = sQuerry + "," + sColums[nIndex] + " " + sColums[nIndex + 1];
sQuerry += ")";
DBWrapper.ExecuteNonQueryEx(sQuerry);
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例6: LogMessagesTo
private static void LogMessagesTo(TraceSource traceSource)
{
var log = new Log(traceSource);
log.Verbose(_verboseMessage);
log.Information(_infoMessage);
log.Warning(_warningMessage);
log.Error(_errorMessage);
traceSource.Flush();
}
示例7: Application_Error
protected void Application_Error(object sender,EventArgs e)
{
ILog _log = new Log();
StringBuilder content = new StringBuilder();
HttpRequest request = HttpContext.Current.Request;
content.AppendFormat("\r\nNavigator:{0}", request.UserAgent);
content.AppendFormat("\r\nIp:{0}", request.UserHostAddress);
content.AppendFormat("\r\nUrlReferrer:{0}", request.UrlReferrer != null ? request.UrlReferrer.AbsoluteUri : "");
content.AppendFormat("\r\nRequest:{0}", Utils.GetRequestValues(request));
content.AppendFormat("\r\nUrl:{0}", request.Url.AbsoluteUri);
_log.Error(content.ToString(), Server.GetLastError().GetBaseException());//记录日志
}
示例8: DealError
//-----------------------------------------------------------------------------------------
/// <summary>
/// 处理错误
/// </summary>
/// <param name="e"></param>
protected void DealError(Exception e)
{
Log log = new Log(typeof(BllBase));
log.Error(e);
//DateTime dt = DateTime.Now;
//string errorLogName = String.Format("{0}{1}_Error.txt", APPLICATION_ERROR_PATH, dt.ToString("yyyyMMdd"));
//using (StreamWriter sw = new StreamWriter(errorLogName, true, Encoding.GetEncoding("gb2312")))
//{
// sw.WriteLine(String.Format("[{0}]{1}\r\n"
// , dt.ToString("HH:mm:hh")
// , e.ToString()));
//}
}
示例9: Login
public Login()
{
using (Log log = new Log("Glx.App.Login::Login()"))
{
try
{
DBWrapper.InitializeDB("\\database\\GlxDB.mdf", true);
InitializeComponent();
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例10: Main
static void Main(string[] args)
{
Log log = new Log();
Migrator migrator = null;
AbstractParser parser = null;
try
{
parser = Factory.Create(args);
}
catch (Exception ex)
{
Console.Write(GetHelp(parser));
log.Error("Could not continue: " + ex.Message);
Exit(1);
}
try
{
migrator = parser.Parse(args, new Migrator());
}
catch (Exception ex)
{
Console.Write(GetHelp(parser));
log.Error("Error: " + ex.Message);
Exit(1);
}
if (migrator != null)
{
migrator.Run();
}
Exit(Environment.ExitCode);
}
示例11: CopyFile
internal static bool CopyFile(string file, string destinationFolder, Log log)
{
try
{
var sourceFileName = Path.GetFileName(file);
if (sourceFileName == null || !File.Exists(file))
{
log.Error("File not found {0}", file);
return false;
}
var destinationFilePath = Path.Combine(destinationFolder, sourceFileName);
if (File.Exists(destinationFilePath))
{
File.Delete(destinationFilePath);
}
File.Copy(file, destinationFilePath);
}
catch (Exception e)
{
log.Error(e.Message);
return false;
}
return true;
}
示例12: Table
/// <summary>
/// Constructor : creates string array from entered string
/// Working: Converts "Column1,Column2,Column3" to string[3]
/// </summary>
/// <param name="Columns_i"></param>
public Table( string Columns_i )
{
using (Log log = new Log("Glx.DB.Table::Table()"))
{
try
{
sColumns = Columns_i;
Columns = Strings.Split(Columns_i, ",", -1, CompareMethod.Text);
nColumnCount = Columns.Length;
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
示例13: using
/// <summary>
/// Returns the index of a column by the statement: TableObject/"column_name"
/// </summary>
/// <param name="t"></param>
/// <param name="sColumn"></param>
/// <returns></returns>
public static int operator /( Table t, string sColumn )
{
using (Log log = new Log("Glx.DB.Table::/()"))
{
try
{
for (int nIndex = 0; nIndex < t.nColumnCount; nIndex++)
if (String.Compare(sColumn, t.Columns[nIndex], true) == 0)
return nIndex;
}
catch (Exception ex)
{
log.Error(ex);
return -1;
}
}
return -1;
}
示例14: GetAddInIconFromDll
/// <summary>
/// Load a dll file( AddIn file ) and get a user control named 'Icon' for Executing the AddIn
/// </summary>
/// <param name="sDllFileName"></param>
/// <param name="sUserControlName"></param>
/// <returns></returns>
public static UserControl GetAddInIconFromDll(string sDllFileName)
{
using (Log log = new Log("Glx.Common.::GetAddInIconFromDll()"))
{
try
{
Assembly assembly = Assembly.LoadFile(@sDllFileName);
object obj;
Type myType = assembly.GetType("Glx.AddIn.Icon");
obj = Activator.CreateInstance(myType);
UserControl userControl = (UserControl)obj;
return userControl;
}
catch (Exception ex)
{
log.Error(ex);
return null;
}
}
}
示例15: Main
public static void Main(string[] args)
{
if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/settings.json"))
{
Configuration config = Configuration.LoadConfiguration(AppDomain.CurrentDomain.BaseDirectory + "/settings.json");
Log mainLog = new Log(config.MainLog, null);
foreach (Configuration.BotInfo info in config.Bots)
{
mainLog.Info("Launching Bot " + info.DisplayName + "...");
new Thread(() =>
{
int crashes = 0;
while (crashes < 1000)
{
try
{
new Bot(info, config.ApiKey, (Bot bot, SteamID sid) =>
{
return (SteamBot.UserHandler)System.Activator.CreateInstance(Type.GetType(info.BotControlClass), new object[] { bot, sid });
});
}
catch (Exception e)
{
mainLog.Error("Error With Bot: " + e);
crashes++;
}
}
}).Start();
Thread.Sleep(5000);
}
MySQL.start();
}
else
{
Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
Console.WriteLine("Configuration File Does not exist. Please rename 'settings-template.json' to 'settings.json' and modify the settings to match your environment");
}
}