本文整理汇总了C#中ILogger.LogException方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.LogException方法的具体用法?C# ILogger.LogException怎么用?C# ILogger.LogException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.LogException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QBRepository
public QBRepository(ILogger logger, ISettings settings)
{
_logger = logger;
_settings = settings;
try
{
_qbSession = new QBSessionManagerClass();
}
catch (Exception e)
{
_logger.LogException("Error creating QBSessionManagerClass object in QBRepository constructor.", e);
}
}
示例2: AddRunSettings
public IXPathNavigable AddRunSettings(IXPathNavigable userRunSettingDocument,
IRunSettingsConfigurationInfo configurationInfo, ILogger logger)
{
XPathNavigator userRunSettingsNavigator = userRunSettingDocument.CreateNavigator();
Debug.Assert(userRunSettingsNavigator != null, "userRunSettingsNavigator == null!");
if (!userRunSettingsNavigator.MoveToChild("RunSettings", ""))
{
logger.Log(MessageLevel.Warning, "RunSettingsDocument does not contain a RunSettings node! Canceling settings merging...");
return userRunSettingsNavigator;
}
var finalRunSettings = new RunSettings();
if (CopyToUnsetValues(userRunSettingsNavigator, finalRunSettings))
{
userRunSettingsNavigator.DeleteSelf(); // this node is to be replaced by the final run settings
}
string solutionRunSettingsFile = GetSolutionSettingsXmlFile();
try
{
if (File.Exists(solutionRunSettingsFile))
{
var solutionRunSettingsDocument = new XPathDocument(solutionRunSettingsFile);
XPathNavigator solutionRunSettingsNavigator = solutionRunSettingsDocument.CreateNavigator();
if (solutionRunSettingsNavigator.MoveToChild("RunSettings", ""))
{
CopyToUnsetValues(solutionRunSettingsNavigator, finalRunSettings);
}
}
}
catch (Exception e)
{
logger.Log(MessageLevel.Warning,
$"Solution test settings file could not be parsed, check file: {solutionRunSettingsFile}");
logger.LogException(e);
}
finalRunSettings.GetUnsetValuesFrom(_globalRunSettings.RunSettings);
userRunSettingsNavigator.AppendChild(finalRunSettings.ToXml().CreateNavigator());
userRunSettingsNavigator.MoveToRoot();
return userRunSettingsNavigator;
}
示例3: frmMain
public frmMain(ILogger logger, QBRepository qbRepo, ISettings settings, frmCustomerSearch fCustSearch, IFileSystemRepository fsRepo, SalesItemsRepository salesItemsRepo)
{
InitializeComponent();
try
{
_ucContacts = ucGridContacts;
_ucSwatchOrders = ucSwatches;
_ucPendingOrders = ucGridPendingOrders;
_logger = logger;
_qbRepo = qbRepo;
_settings = settings;
_fCustomerSearch = fCustSearch;
_fsRepo = fsRepo;
_salesItemsRepository = salesItemsRepo;
_fCustomerSearch.Text = "QuickBooks Customers";
if (_settings.IsInitialStartup)
{
ShowSettingsForm();
}
LoadCboPendingSince();
TestForQuickBooksConnection();
SetConnectionBasedUiElements();
CacheSalesItemsFromAppConfigFile();
}
catch (Exception ex)
{
_logger.LogException("There was an error in frmMain load.", ex);
MessageBox.Show("There was an error on application startup (see the log for details). The error may be related to incorrect settings. The settings are located under View > Settings.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例4: OnStart
protected override void OnStart(string[] args)
{
_logger = new Logger();
try
{
var contentServers = new List<IPEndPoint>
{
new IPEndPoint(new IPAddress(new byte[] {127, 0, 0, 1}), 8081),
new IPEndPoint(new IPAddress(new byte[] {127, 0, 0, 1}), 8082)
};
var endPoint = new IPEndPoint(new IPAddress(new byte[] {127, 0, 0, 1}), 80);
var portListener = new PortListener(endPoint);
_httpProxy = new HttpProxy(contentServers, portListener, new RequestMessageBuilder(), new ResponseStreamWriter());
_httpProxy.Start();
}
catch (Exception ex)
{
_logger.LogException(ex);
}
}
示例5: CrawlGames
//.........这里部分代码省略.........
Log("Active games: {0}", games.Count);
foreach (var game in games)
{
if (game.Examined || game.InSetup)
continue;
bool containsKey;
lock (observingGames)
{
containsKey = observingGames.ContainsKey(game.Id);
}
if (!containsKey)
{
try
{
// Add game to the list
var observingGame = new ObservingGame();
observingGame.BlackMovesList = new List<ChessMove>();
observingGame.WhiteMovesList = new List<ChessMove>();
observingGame.Game = game;
lock (observingGames)
{
observingGames.Add(game.Id, observingGame);
}
// Start observing game
var result = await client.StartObservingGame(game);
// If we started observing different game, stop observing it
if (!result.GameInfo.WhitePlayer.Username.StartsWith(game.WhitePlayer.Username)
|| !result.GameInfo.BlackPlayer.Username.StartsWith(game.BlackPlayer.Username))
{
Log("Canceling game {0}", game);
await client.StopObservingGame(game);
}
Log("Starting game {0}", game);
// Collect and update moves list
var moveList = await client.GetMoveList(game);
observingGame.GameStarted = moveList.GameStarted;
lock (observingGame.WhiteMovesList)
{
while (observingGame.WhiteMovesList.Count < moveList.WhiteMoves.Count)
observingGame.WhiteMovesList.Add(null);
for (int i = 0; i < moveList.WhiteMoves.Count; i++)
observingGame.WhiteMovesList[i] = moveList.WhiteMoves[i];
}
lock (observingGame.BlackMovesList)
{
while (observingGame.BlackMovesList.Count < moveList.BlackMoves.Count)
observingGame.BlackMovesList.Add(null);
for (int i = 0; i < moveList.BlackMoves.Count; i++)
observingGame.BlackMovesList[i] = moveList.BlackMoves[i];
}
// Connect partners game
if (result.GameInfo.PartnersGameId > 0)
{
ObservingGame partnersGame;
lock (observingGames)
{
if (observingGames.TryGetValue(result.GameInfo.PartnersGameId, out partnersGame))
{
partnersGame.PartnersGame = observingGame;
observingGame.PartnersGame = partnersGame;
}
}
}
}
catch (Exception ex)
{
logger.LogException(ex);
lock (observingGames)
{
observingGames.Remove(game.Id);
}
try
{
await client.StopObservingGame(game.Id);
}
catch (Exception)
{
// We want to swallow this exception
}
}
}
}
await Task.Delay(TimeSpan.FromSeconds(10));
}
}
}