本文整理汇总了C#中ILoggerService.LogError方法的典型用法代码示例。如果您正苦于以下问题:C# ILoggerService.LogError方法的具体用法?C# ILoggerService.LogError怎么用?C# ILoggerService.LogError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILoggerService
的用法示例。
在下文中一共展示了ILoggerService.LogError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static int Main(string[] args)
{
LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set
Logger = LoggerServiceFactory.GetLogger(typeof(WordCountExample));
if (args.Length != 1)
{
Console.Error.WriteLine("Usage: WordCount <file>");
return 1;
}
var sparkContext = new SparkContext(new SparkConf().SetAppName("MobiusWordCount"));
try
{
var lines = sparkContext.TextFile(args[0]);
var counts = lines
.FlatMap(x => x.Split(' '))
.Map(w => new KeyValuePair<string, int>(w, 1))
.ReduceByKey((x, y) => x + y);
foreach (var wordcount in counts.Collect())
{
Console.WriteLine("{0}: {1}", wordcount.Key, wordcount.Value);
}
}
catch (Exception ex)
{
Logger.LogError("Error performing Word Count");
Logger.LogException(ex);
}
sparkContext.Stop();
return 0;
}
示例2: Main
public static void Main(string[] args)
{
LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set
Logger = LoggerServiceFactory.GetLogger(typeof(PiExample));
var sparkContext = new SparkContext(new SparkConf());
try
{
const int slices = 3;
var numberOfItems = (int)Math.Min(100000L * slices, int.MaxValue);
var values = new List<int>(numberOfItems);
for (var i = 0; i <= numberOfItems; i++)
{
values.Add(i);
}
var rdd = sparkContext.Parallelize(values, slices);
CalculatePiUsingAnonymousMethod(numberOfItems, rdd);
CalculatePiUsingSerializedClassApproach(numberOfItems, rdd);
Logger.LogInfo("Completed calculating the value of Pi");
}
catch (Exception ex)
{
Logger.LogError("Error calculating Pi");
Logger.LogException(ex);
}
sparkContext.Stop();
}
示例3: CleanDirectory
public void CleanDirectory(string device, string path, ILoggerService logger)
{
var fullPath = $"\\\\{device}\\C$" + path;
try
{
Directory.Delete(fullPath, true);
logger.LogMessage($"Cleaned directory {fullPath}");
}
catch (Exception ex)
{
ResultConsole.Instance.AddConsoleLine($"Failed to clean directory {fullPath}. Due to exception {ex.Message}");
logger.LogError($"Failed to clean directory {fullPath}.", ex);
}
}
示例4: CreateRemoteTextFile
public async void CreateRemoteTextFile(string filepath, string contents, ILoggerService logger)
{
if (File.Exists(filepath)) return;
try
{
using (var outfile = new StreamWriter(filepath, true))
{
await outfile.WriteAsync(contents);
outfile.Close();
}
}
catch (Exception e)
{
logger.LogError($"Unable to create remote file {filepath}", e);
}
}
示例5: WriteToTextFile
public void WriteToTextFile(string filepath, string contents, ILoggerService logger)
{
var sb = new StringBuilder();
sb.Append(contents);
using (var outfile = new StreamWriter(filepath, true))
{
try
{
outfile.WriteAsync(sb.ToString());
}
catch (Exception e)
{
logger.LogError($"Unable to write to directory {filepath}", e);
}
}
}
示例6: Main
static void Main(string[] args)
{
// if there exists exe.config file, then use log4net
if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
{
LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance);
}
logger = LoggerServiceFactory.GetLogger(typeof(Worker));
Socket sock = null;
try
{
PrintFiles();
int javaPort = int.Parse(Console.ReadLine());
logger.LogInfo("java_port: " + javaPort);
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Connect(IPAddress.Loopback, javaPort);
}
catch (Exception e)
{
logger.LogError("CSharpWorker failed with exception:");
logger.LogException(e);
Environment.Exit(-1);
}
using (NetworkStream s = new NetworkStream(sock))
{
try
{
DateTime bootTime = DateTime.UtcNow;
int splitIndex = SerDe.ReadInt(s);
logger.LogInfo("split_index: " + splitIndex);
if (splitIndex == -1)
Environment.Exit(-1);
string ver = SerDe.ReadString(s);
logger.LogInfo("ver: " + ver);
//// initialize global state
//shuffle.MemoryBytesSpilled = 0
//shuffle.DiskBytesSpilled = 0
// fetch name of workdir
string sparkFilesDir = SerDe.ReadString(s);
logger.LogInfo("spark_files_dir: " + sparkFilesDir);
//SparkFiles._root_directory = sparkFilesDir
//SparkFiles._is_running_on_worker = True
// fetch names of includes - not used //TODO - complete the impl
int numberOfIncludesItems = SerDe.ReadInt(s);
logger.LogInfo("num_includes: " + numberOfIncludesItems);
if (numberOfIncludesItems > 0)
{
for (int i = 0; i < numberOfIncludesItems; i++)
{
string filename = SerDe.ReadString(s);
}
}
// fetch names and values of broadcast variables
int numBroadcastVariables = SerDe.ReadInt(s);
logger.LogInfo("num_broadcast_variables: " + numBroadcastVariables);
if (numBroadcastVariables > 0)
{
for (int i = 0; i < numBroadcastVariables; i++)
{
long bid = SerDe.ReadLong(s);
if (bid >= 0)
{
string path = SerDe.ReadString(s);
Broadcast.broadcastRegistry[bid] = new Broadcast(path);
}
else
{
bid = -bid - 1;
Broadcast.broadcastRegistry.Remove(bid);
}
}
}
Accumulator.accumulatorRegistry.Clear();
int lengthOCommandByteArray = SerDe.ReadInt(s);
logger.LogInfo("command_len: " + lengthOCommandByteArray);
IFormatter formatter = new BinaryFormatter();
if (lengthOCommandByteArray > 0)
{
Stopwatch commandProcessWatch = new Stopwatch();
Stopwatch funcProcessWatch = new Stopwatch();
commandProcessWatch.Start();
int rddId = SerDe.ReadInt(s);
int stageId = SerDe.ReadInt(s);
int partitionId = SerDe.ReadInt(s);
logger.LogInfo(string.Format("rddInfo: rddId {0}, stageId {1}, partitionId {2}", rddId, stageId, partitionId));
//.........这里部分代码省略.........
示例7: Main
static void Main(string[] args)
{
// if there exists exe.config file, then use log4net
if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
{
LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance);
}
logger = LoggerServiceFactory.GetLogger(typeof(Worker));
Socket sock = null;
try
{
PrintFiles();
int javaPort = int.Parse(Console.ReadLine());
logger.LogInfo("java_port: " + javaPort);
sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Connect(IPAddress.Parse("127.0.0.1"), javaPort);
}
catch (Exception e)
{
logger.LogError("CSharpWorker failed with exception:");
logger.LogException(e);
Environment.Exit(-1);
}
using (NetworkStream s = new NetworkStream(sock))
{
try
{
DateTime bootTime = DateTime.UtcNow;
int splitIndex = SerDe.ReadInt(s);
logger.LogInfo("split_index: " + splitIndex);
if (splitIndex == -1)
Environment.Exit(-1);
string ver = SerDe.ReadString(s);
logger.LogInfo("ver: " + ver);
//// initialize global state
//shuffle.MemoryBytesSpilled = 0
//shuffle.DiskBytesSpilled = 0
// fetch name of workdir
string sparkFilesDir = SerDe.ReadString(s);
logger.LogInfo("spark_files_dir: " + sparkFilesDir);
//SparkFiles._root_directory = sparkFilesDir
//SparkFiles._is_running_on_worker = True
// fetch names of includes - not used //TODO - complete the impl
int numberOfIncludesItems = SerDe.ReadInt(s);
logger.LogInfo("num_includes: " + numberOfIncludesItems);
if (numberOfIncludesItems > 0)
{
for (int i = 0; i < numberOfIncludesItems; i++)
{
string filename = SerDe.ReadString(s);
}
}
// fetch names and values of broadcast variables
int numBroadcastVariables = SerDe.ReadInt(s);
logger.LogInfo("num_broadcast_variables: " + numBroadcastVariables);
if (numBroadcastVariables > 0)
{
for (int i = 0; i < numBroadcastVariables; i++)
{
long bid = SerDe.ReadLong(s);
if (bid >= 0)
{
string path = SerDe.ReadString(s);
Broadcast.broadcastRegistry[bid] = new Broadcast(path);
}
else
{
bid = -bid - 1;
Broadcast.broadcastRegistry.Remove(bid);
}
}
}
Accumulator.accumulatorRegistry.Clear();
int lengthOCommandByteArray = SerDe.ReadInt(s);
logger.LogInfo("command_len: " + lengthOCommandByteArray);
IFormatter formatter = new BinaryFormatter();
if (lengthOCommandByteArray > 0)
{
string deserializerMode = SerDe.ReadString(s);
logger.LogInfo("Deserializer mode: " + deserializerMode);
string serializerMode = SerDe.ReadString(s);
logger.LogInfo("Serializer mode: " + serializerMode);
byte[] command = SerDe.ReadBytes(s);
//.........这里部分代码省略.........
示例8: TryFinishOAuthFlow
/// <summary>
/// Tries to get information the service provider and revalidates it.
/// </summary>
/// <param name="tokenManager"></param>
/// <param name="reissueCallback">If not null, the flow will be restarted/reissued when the parameters are incorrect (due to token invalid or expired).</param>
/// <param name="userId"></param>
/// <param name="accessToken"></param>
/// <returns>true if success, false if fail</returns>
public static bool TryFinishOAuthFlow(IConsumerTokenManager tokenManager, ILoggerService logger, out long userId, out string accessToken)
{
bool success = false;
var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, tokenManager);
userId = 0;
accessToken = null;
// Is Twitter calling back with authorization?
try
{
var accessTokenResponse = twitter.ProcessUserAuthorization();
if (accessTokenResponse != null)
{
accessToken = accessTokenResponse.AccessToken;
userId = Convert.ToInt64(accessTokenResponse.ExtraData["user_id"]);
success = true;
}
}
catch (DotNetOpenAuth.Messaging.ProtocolException ex)
{
//Can failed because the token manager didn't find the key or the service is not available.
logger.LogError(ex);
}
return success;
}