本文整理汇总了C#中System.Logger.Warn方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.Warn方法的具体用法?C# Logger.Warn怎么用?C# Logger.Warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Logger
的用法示例。
在下文中一共展示了Logger.Warn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoggerGenerateOutputTest
public void LoggerGenerateOutputTest()
{
Logger logger = new Logger(System.Reflection.Assembly.GetExecutingAssembly());
logger.Exception("exception #1");
logger.Exception("exception #2");
logger.Exception("exception #3");
logger.Exception("exception #4");
logger.Error("Error 1");
logger.Error("Error 2");
logger.Error("Error 3");
logger.Warn("Warn 1");
logger.Warn("Warn 2");
logger.Warn("Warn 3");
string id = logger.LogResume();
Assert.Pass(id);
}
示例2: ExampleTwo
private static void ExampleTwo()
{
var simpleLayout = new SimpleLayout();
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(string.Format("User {0} successfully registered.", "Pesho"));
logger.Warn("Warning - missing files.");
}
示例3: ExampleFour
private static void ExampleFour()
{
var simpleLayout = new SimpleLayout();
var consoleAppender = new ConsoleAppender(simpleLayout);
consoleAppender.ReportLevel = 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");
}
示例4: DispatchData
public static void DispatchData(IDataProducer producer, object data, bool cloneDataOnFork, DispatchPolicy dispatchPolicy,
Set<IDataConsumer> dataConsumers, Logger logger)
{
if (data == null) { return; }
if (dataConsumers.Count == 0)
{
if (logger != null) { logger.Warn("DispatchData", "Data ready but nobody is listening."); }
return;
}
if (dispatchPolicy == DispatchPolicy.BalanceLoadSum || dispatchPolicy == DispatchPolicy.BalanceLoadMax)
{
if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (load balancing) ...", data.GetType()); }
int minLoad = int.MaxValue;
IDataConsumer target = null;
foreach (IDataConsumer consumer in dataConsumers)
{
int load = (dispatchPolicy == DispatchPolicy.BalanceLoadSum) ? GetBranchLoadSum(consumer) : GetBranchLoadMax(consumer);
if (load < minLoad) { minLoad = load; target = consumer; }
}
target.ReceiveData(producer, data);
}
else if (dispatchPolicy == DispatchPolicy.Random)
{
if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (random policy) ...", data.GetType()); }
ArrayList<IDataConsumer> tmp = new ArrayList<IDataConsumer>(dataConsumers.Count);
foreach (IDataConsumer dataConsumer in dataConsumers) { tmp.Add(dataConsumer); }
tmp[mRandom.Next(0, tmp.Count)].ReceiveData(producer, data);
}
else
{
if (logger != null) { logger.Trace("DispatchData", "Dispatching data of type {0} (to-all policy) ...", data.GetType()); }
if (dataConsumers.Count > 1 && cloneDataOnFork)
{
foreach (IDataConsumer dataConsumer in dataConsumers)
{
dataConsumer.ReceiveData(producer, Utils.Clone(data, /*deepClone=*/true));
}
}
else
{
foreach (IDataConsumer dataConsumer in dataConsumers)
{
dataConsumer.ReceiveData(producer, data);
}
}
}
if (logger != null) { logger.Trace("DispatchData", "Data dispatched."); }
}
示例5: WlanClient
public WlanClient()
{
ItsLogger = new Logger(this);
try
{
Wlan.ThrowIfError(Wlan.WlanOpenHandle(1, IntPtr.Zero, out _negotiatedVersion, out _clientHandle));
WlanNotificationCallback = new Wlan.WlanNotificationCallbackDelegate(OnWlanNotification);
Wlan.WlanNotificationSource source;
Wlan.ThrowIfError(Wlan.WlanRegisterNotification(_clientHandle, Wlan.WlanNotificationSource.All, false, WlanNotificationCallback, IntPtr.Zero, IntPtr.Zero, out source));
}
catch (Win32Exception ex)
{
Wlan.WlanCloseHandle(_clientHandle, IntPtr.Zero);
ItsLogger.Warn(ex.Message);
throw;
}
}
示例6: GetOutcome
private static GlobalSingleInstanceResponseOutcome? GetOutcome(ICollection<RemoteClusterActivationResponse> responses, GrainId grainId, Logger logger, bool hasPendingResponses)
{
if (!hasPendingResponses && responses.All(res => res.ResponseStatus == ActivationResponseStatus.Pass))
{
// All passed, or no other clusters exist
return GlobalSingleInstanceResponseOutcome.Succeed;
}
var ownerResponses = responses
.Where(res => res.ResponseStatus == ActivationResponseStatus.Failed && res.Owned == true).ToList();
if (ownerResponses.Count > 0)
{
if (ownerResponses.Count > 1)
logger.Warn((int)ErrorCode.GlobalSingleInstance_MultipleOwners, "GSIP:Req {0} Unexpected error occured. Multiple Owner Replies.", grainId);
return new GlobalSingleInstanceResponseOutcome(OutcomeState.RemoteOwner, ownerResponses[0].ExistingActivationAddress, ownerResponses[0].ClusterId);
}
// are all responses here or have failed?
if (!hasPendingResponses)
{
// determine best candidate
var candidates = responses
.Where(res => res.ResponseStatus == ActivationResponseStatus.Failed && res.ExistingActivationAddress.Address != null)
.ToList();
AddressAndTag remoteOwner = new AddressAndTag();
string remoteOwnerCluster = null;
foreach (var res in candidates)
{
if (remoteOwner.Address == null ||
MultiClusterUtils.ActivationPrecedenceFunc(grainId, res.ClusterId, remoteOwnerCluster))
{
remoteOwner = res.ExistingActivationAddress;
remoteOwnerCluster = res.ClusterId;
}
}
var outcome = remoteOwner.Address != null ? OutcomeState.RemoteOwnerLikely : OutcomeState.Inconclusive;
return new GlobalSingleInstanceResponseOutcome(outcome, remoteOwner, remoteOwnerCluster);
}
return null;
}
示例7: ListAllUsers
/// <summary>
/// <see cref="INoteManagerService.ListAllUsers"/>
/// </summary>
/// <param name="id"></param>
public UserDTO[] ListAllUsers()
{
Logger logger = new Logger(this.GetType());
logger.Debug("debug");
logger.Error("error");
logger.Info("info");
logger.Warn("warn");
using (var nme = new NoteManagerEntities())
{
var allUsers = from u in nme.User select u;
List<UserDTO> res = new List<UserDTO>();
foreach (var u in allUsers)
{
res.Add(new UserDTO(u));
}
return res.ToArray();
}
}