本文整理汇总了C#中Logger.Error方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Error方法的具体用法?C# Logger.Error怎么用?C# Logger.Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.Error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ADClient
public ActiveDirectoryClient ADClient(IConfiguration Configuration, IAuthenticationProvidor authProvidor, Logger Logger)
{
ActiveDirectoryClient activeDirectoryClient;
try
{
Logger.Debug(@"Connecting to Azure Active Directory GraphAPI to get ClientSession");
activeDirectoryClient = authProvidor.GetActiveDirectoryClientAsApplication(Configuration);
if (activeDirectoryClient != null)
{
return activeDirectoryClient;
}
else
{
return null;
}
}
catch (AuthenticationException ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Acquiring a token failed with the following error: {0}", ex.Message);
Logger.Error(String.Format(@"Could not aquire Azure active Directory Authentication Token {0}", ex.Message));
if (ex.InnerException != null)
{
//InnerException Message will contain the HTTP error status codes mentioned in the link above
Console.WriteLine("Error detail: {0}", ex.InnerException.Message);
Logger.Error(String.Format(@"Error detail {0}", ex.InnerException));
}
Console.ResetColor();
return null;
}
}
示例2: GetADGroup
public Group GetADGroup(ActiveDirectoryClient ADClient, string GroupNameSearchString, Logger Logger)
{
List<IGroup> foundGroups = null;
try
{
Logger.Debug(string.Format("Searching/Fetching AD Group {0}", GroupNameSearchString));
foundGroups = ADClient.Groups
.Where(group => group.DisplayName.StartsWith(GroupNameSearchString))
.ExecuteAsync().Result.CurrentPage.ToList();
}
catch (Exception ex)
{
Console.WriteLine("Error when fetching group from Azure Active Directory {0} {1}", ex.Message, ex.InnerException != null ? ex.InnerException.Message : "");
Logger.Error(String.Format("Error when fetching group from Azure Active Directory {0} {1}", ex.Message, ex.InnerException != null ? ex.InnerException.Message : ""));
}
if (foundGroups != null && foundGroups.Count > 0)
{
return foundGroups.First() as Group;
}
else
{
return null;
}
}
示例3: Launch
public int Launch()
{
CommonOptions commonOptions = _modeRunner.CommonOptions;
IDirectoryLocation outFolder = commonOptions.OutputDirectory;
var log = outFolder.GetFileLocation("CanvasLog.txt");
var error = outFolder.GetFileLocation("CanvasError.txt");
using (ILogger logger = new Logger(log, error))
{
try
{
logger.Info($"Running Canvas {_mode} {_version}");
logger.Info($"Command-line arguments: {string.Join(" ", _args)}");
using (ICheckpointRunner checkpointRunner =
GetCheckpointRunner(
logger,
outFolder,
commonOptions.StartCheckpoint,
commonOptions.StopCheckpoint,
commonOptions.WholeGenomeFasta))
{
IDirectoryLocation loggingFolder = outFolder.CreateSubdirectory(IsasFilePaths.LoggingFolderName);
IsasConfiguration config = IsasConfiguration.GetConfiguration();
IWorkManager workManager = new LocalWorkManager(logger, loggingFolder, 0, config.MaximumMemoryGB, config.MaximumHoursPerProcess);
_modeRunner.Run(logger, checkpointRunner, workManager);
}
}
catch (Exception e)
{
logger.Error($"Canvas workflow error: {e}");
return -1;
}
}
return 0;
}
示例4: Main
public static void Main()
{
ILayout simpleLayout = new SimpleLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
var fileAppender = new FileAppender(simpleLayout);
fileAppender.File = "../../log.txt";
var logger = new Logger(consoleAppender, fileAppender);
logger.Error("Error parsing JSON.");
logger.Info(string.Format("User {0} successfully registered.", "Dobri"));
logger.Warn("Warning - missing files.");
var xmlLayout = new XmlLayout();
consoleAppender = new ConsoleAppender(xmlLayout);
logger = new Logger(consoleAppender);
logger.Fatal("mscorlib.dll does not respond");
logger.Critical("No connection string found in App.config");
consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例5: Run
public static int Run(Logger logger, int parentProcessId)
{
// get parent process which will be monitored
Process parentProcess = null;
if (parentProcessId != 0)
{
try
{
parentProcess = Process.GetProcessById(parentProcessId);
}
catch (Exception e)
{
logger.Error(e, "Cannot find parentProcess (Id={0})", parentProcessId);
return 1;
}
}
// open service
try
{
var address = "net.pipe://localhost/Unity3D.IncrementalCompiler/" + parentProcessId;
var serviceHost = new ServiceHost(typeof(CompilerService));
var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
{
MaxBufferSize = 1048576,
MaxReceivedMessageSize = 1048576
};
serviceHost.AddServiceEndpoint(typeof(ICompilerService), binding, address);
serviceHost.Open();
}
catch (Exception e)
{
logger.Error(e, "Service Host got an error");
return 1;
}
if (parentProcess != null)
{
parentProcess.WaitForExit();
logger.Info("Parent process just exited. (PID={0})", parentProcess.Id);
}
return 0;
}
示例6: TestLogging
private static void TestLogging()
{
var logger = new Logger<CommonRegistry>();
logger.Debug("Testing Debug Log.");
logger.Info("Testing Info Log.");
logger.Warn("Testing Warn Log.");
logger.Error("Testing Error Log.");
}
示例7: TestInterfaces
private static void TestInterfaces()
{
ILayuot simpleLayout = new SimpleLayuot();
IAppender consoleAppender =
new ConsoleAppender(simpleLayout);
ILogger logger = new Logger(consoleAppender);
logger.Error("Error parsing JSON.");
logger.Info($"User {"Pesho"} successfully registered.");
}
示例8: TestFileAppender
private static void TestFileAppender()
{
var simpleLayout = new SimpleLayuot();
var consoleAppender = new ConsoleAppender(simpleLayout);
var fileAppender = new FileAppender(simpleLayout);
fileAppender.File = "log.txt";
var logger = new Logger(consoleAppender, fileAppender);
logger.Error("Error parsing JSON.");
logger.Info($"User {"Pesho"} successfully registered.");
logger.Warn("Warning - missing files.");
}
示例9: Main
public static void Main()
{
var simpleLayout = new SimpleLayout();
var jsonLayout = new JsonLayout();
// var myLayout = new SoftUniLayout();
var consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
consoleAppender.ReportLevel = ReportLevel.Error;
var fileAppender = new FileAppendder(jsonLayout, "../../Log.txt");
fileAppender.ReportLevel = ReportLevel.Error;
var logger = new Logger(consoleAppender, fileAppender);
logger.Error("Error parsing JSON.");
logger.Warning("User John successfully registered");
logger.Info("Everything seems fine");
logger.Warning("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
fileAppender.Close();
}
示例10: Main
static void Main(string[] args)
{
ILayout simpleLayout = new SimpleLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = ReportLevel.Error;
ILogger logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例11: TestTreshold
private static void TestTreshold()
{
var simpleLayout = new SimpleLayuot();
var consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.Treshold = ReportLevel.Error;
var logger = new Logger(consoleAppender);
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
示例12: Main
public static void Main()
{
try
{
var simpleLayout = new SimpleLayout();
var xmlLayout = new XmlLayout();
IAppender consoleAppender = new ConsoleAppender(simpleLayout);
IAppender fileAppender = new FileAppender(simpleLayout);
fileAppender.File = "../../log.txt";
IAppender fileAppenderXml = new FileAppender(xmlLayout);
fileAppenderXml.File = "../../log.xml";
ILogger logger = new Logger(consoleAppender, fileAppender, fileAppenderXml);
// add in logs
logger.Error("Error parsing JSON.");
logger.Info(string.Format("User {0} successfully registered.", "Pesho"));
logger.Warn("Warn - missing files.");
logger.Fatal("mscorlib.dll does not respond");
logger.Critical("No connection string found in App.config");
logger.Info("Everything seems fine");
logger.Warn("Warning: ping is too high - disconnect imminent");
logger.Error("Error parsing request");
logger.Critical("No connection string found in App.config");
logger.Fatal("mscorlib.dll does not respond");
}
catch (ArgumentException ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine();
}
示例13: DvseSerialEdlComThread
/// <summary>
/// Initializes a new instance of the <see cref="DvseSerialEdlComThread"/> class.
/// </summary>
/// <param name="portName">Name of the port.</param>
public DvseSerialEdlComThread(string portName)
{
logger = LogManager.GetLogger(portName);
Trace.WriteLine($"------ {DateTime.Now} Creating serial com thread for port [{portName}].");
logger.Info("Creating serial com thread for port [{0}].", portName);
// Check if com port exisists.
if (machinePorts.Contains(portName) == false)
{
logger.Error("On this machine no COM port '{0}' found.", portName);
throw new FaultException($"On this machine no COM port '{portName}' found.");
}
ActiveTariffWrittenAt = new DateTime(0);
OperationModeWrittenAt = new DateTime(0);
this.portName = portName;
logger.Info("Serial com thread for port [{0}] created.", portName);
}
示例14: Main
static void Main(string[] args)
{
Log = Logger.GetInstance();
Log.Info("Starting up");
TcpServer server = null;
if(UsingTls(args))
{
Log.Info("Using TLS");
X509Certificate2 cert = null;
var foundCert = TryGetX509Certificate(args, out cert);
// We have a certificate, so create the server
if (foundCert)
{
server = new TlsServer(IPAddress.Any, DEFAULT_PORT, cert);
}
}
else
{
Log.Warning("Not using TLS");
//insecure version
server = new TcpServer(IPAddress.Any, DEFAULT_PORT);
}
// If we can't start the server, we can't run anything
if(server == null)
{
Log.Error("Could not start the server");
Environment.Exit(1);
}
// All systems go, start the server
var registry = new Registry();
var MessageArchive = new MessageArchive();
var dispatcher = new Dispatcher(server, registry, MessageArchive);
dispatcher.Run();
}
示例15: AuthServer
public AuthServer()
{
_packetLogger = new PacketLogger();
_logger = new Logger() { WriteToConsole = true };
_logger.Load(Path.Combine("logs", string.Format("auth_{0}.log", DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"))));
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
{
Error(s, new ExceptionEventArgs((Exception)e.ExceptionObject));
Environment.Exit(0);
};
_packetLogger.Load("auth_packets.log");
_logger.Info("Loaded Packet Logger");
Stopwatch sw = Stopwatch.StartNew();
AuthConfig.Load();
sw.Stop();
_logger.Info("Loaded Auth Configuration in {0} ms", sw.Elapsed.TotalMilliseconds);
_logger.Info("Starting up server connections...");
_server = new TcpServer(IPAddress.Parse(AuthConfig.Instance.IP), AuthConfig.Instance.Port);
_server.PacketReceived += HandlePacket;
_server.Error += Error;
//
// Initalize a list of ports
//
ushort[] ports = { 38915, 38917 };
for (uint i = 0; ports.Length > i; i++ )
{
// Handle NAT tests before starting...
switch (i)
{
case 0:
_natServer = new UDPClient(ports[0]);
_natServer.PacketReceived += HandleNATTest;
_natServer.Error += Error;
_logger.InfoAuth("NAT Test successful at Port {0}", ports[0]);
break;
case 1:
_natServer2 = new UDPClient(ports[1]);
_natServer2.PacketReceived += HandleNATTest2;
_natServer2.Error += Error;
_logger.InfoAuth("NAT Test successful at Port {0}", ports[1]);
break;
default:
break;
}
}
// Bind to pipe/tcp/http settings in configuration
var isMono = Type.GetType("Mono.Runtime") != null;
switch (AuthConfig.Instance.Remote.Binding)
{
case "pipe":
if (isMono)
{
_logger.Error("pipe is not supported in mono, use http!");
Environment.Exit(1);
return;
}
_remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("localhost/AuthServer/{0}/", SHA256.ComputeHash(AuthConfig.Instance.Remote.Password)));
break;
case "tcp":
if (isMono)
{
_logger.Error("tcp is not supported in mono, use http!");
Environment.Exit(1);
return;
}
_remoteServer = new RemoteServer(this, ERemoteBinding.Pipe, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password)));
break;
case "http":
_remoteServer = new RemoteServer(this, ERemoteBinding.Http, string.Format("{0}:{1}/AuthServer/{2}/", AuthConfig.Instance.Remote.Server, AuthConfig.Instance.Remote.Port, SHA256.ComputeHash(AuthConfig.Instance.Remote.Password)));
break;
default:
_logger.Error("Invalid remote binding '{0}'", AuthConfig.Instance.Remote.Binding);
Environment.Exit(1);
return;
}
_remoteServer.AddServiceEndpoint(typeof(IAuthRemote), "IAuthRemote");
}