本文整理汇总了C#中log4net.ILog.WarnFormat方法的典型用法代码示例。如果您正苦于以下问题:C# ILog.WarnFormat方法的具体用法?C# ILog.WarnFormat怎么用?C# ILog.WarnFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4net.ILog
的用法示例。
在下文中一共展示了ILog.WarnFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Warning
public static void Warning(ILog log, string format, params object[] @params)
{
if (log == null)
{
return;
}
log.WarnFormat(format, @params);
}
示例2: Command
/// <summary>
/// Constructor
/// </summary>
/// <param name="executionPath">Path to the emulator</param>
/// <param name="executionArgs">Arguments to the emulator with replacement variables</param>
/// <param name="argReplacements">String of the form "$VAR=val;$VAR2=val", will be inserted into execution args</param>
public Command(String executionPath, String executionArgs = "", String argReplacements = null)
{
mLogger = LogManager.GetLogger(GetType().Name);
if (!String.IsNullOrEmpty(argReplacements))
{
if (argReplacements.Contains("<") && argReplacements.Contains(";") && argReplacements.Contains(">"))
{
ExecutionArguments = HandleArgumentReplacements(executionArgs, argReplacements);
}
else
{
mLogger.WarnFormat("Replacement argument string was not in the correct format! Required format: \"<VAR>=VAL;<VAR2>=VAL2;etc\". Supplied replacement string was {0}", argReplacements);
ExecutionArguments = executionArgs;
}
}
else
{
ExecutionArguments = executionArgs;
}
ExecutionPath = executionPath;
IsValidCommand = true;
}
示例3: RestartApplication
private void RestartApplication(DeploymentContext context, ILog logger)
{
string virtualDirectoryPath = null;
string[] websitePath = context.Package.Title.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if (websitePath.Length > 1)
{
virtualDirectoryPath = string.Join("/", websitePath.Skip(1).ToArray());
}
using (var website = FindVirtualDirectory("localhost", websitePath[0], virtualDirectoryPath))
{
if (website == null)
{
logger.WarnFormat("No such IIS website found: '{0}'", context.Package.Id);
}
var appPoolId = website.Properties["AppPoolId"].Value;
using (var applicationPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools/" + appPoolId))
{
logger.InfoFormat("Stopping AppPool {0}...", appPoolId);
applicationPool.Invoke("Stop");
logger.InfoFormat("Starting AppPool {0}...", appPoolId);
applicationPool.Invoke("Start");
}
}
}
示例4: get
public BooleanResult get(Dictionary<string,string> settings, string username, string password)
{
m_logger = LogManager.GetLogger(String.Format("pgSMB2[Roaming:{0}]", username));
if (!UserCanBeUsed(username))
{
// user exists and was not created by pgina
m_logger.InfoFormat("user {0} does already exist on this system and does not contain a comment of \"pGina created pgSMB2\"", username);
return new BooleanResult() { Success = true };
}
if (!Connect2share(settings["SMBshare"], username, password, Convert.ToUInt32(settings["ConnectRetry"]), false))
{
return new BooleanResult() { Success = false, Message = string.Format("Unable to connect to {0}", settings["RoamingSource"]) };
}
try
{
if (!Directory.Exists(settings["RoamingSource"]))
{
try
{
Directory.CreateDirectory(settings["RoamingSource"]);
}
catch (Exception ex)
{
m_logger.DebugFormat("CreateDirectory({0}) failed {1}", settings["RoamingSource"], ex.Message);
}
}
string remote_file = settings["RoamingSource"] + "\\" + settings["Filename"];
if (File.Exists(remote_file) || File.Exists(remote_file + ".bak"))
{
// there is a remote file
Boolean loadprofile = true;
// what file to use ?
if (File.Exists(remote_file))
{
settings.Add("Filename_real", settings["Filename"]);
}
else
{
settings.Add("Filename_real", settings["Filename"] + ".bak");
remote_file += ".bak";
}
// is there a local roaming profile (there shouldnt be any)
string ProfDir = GetExistingUserProfile(username, password);
// is this a temp profile
if (!String.IsNullOrEmpty(ProfDir))
{
Abstractions.WindowsApi.pInvokes.structenums.USER_INFO_4 userinfo4 = new Abstractions.WindowsApi.pInvokes.structenums.USER_INFO_4();
if (Abstractions.WindowsApi.pInvokes.UserGet(username, ref userinfo4))
{
if (userinfo4.comment.EndsWith(" tmp"))
{
m_logger.InfoFormat("delete temp profile {0}", ProfDir);
DirectoryDel(ProfDir, 3);
}
}
}
if (File.Exists(ProfDir + "\\ntuser.dat")) //worst case "\\ntuser.dat"
{
// there is a local profile of this user
// we need to compare the write date between the profile and the compressed remote roaming profile
// to be sure that we dont overwrite a newer profile with an old one
// possibly reason is a BSOD/hard reset ...
m_logger.Debug("User " + username + " still own a lokal profile UTCdate:" + File.GetLastWriteTimeUtc(ProfDir + "\\ntuser.dat"));
m_logger.Debug("User " + username + " compressed remote profile UTCdate:" + File.GetLastWriteTimeUtc(remote_file));
if (DateTime.Compare(File.GetLastWriteTimeUtc(ProfDir + "\\ntuser.dat"), File.GetLastWriteTimeUtc(remote_file)) >= 0)
{
m_logger.DebugFormat("the local profile ('{0}') is newer/equal than the remote one, im not downloading the remote one", ProfDir);
loadprofile = false;
}
else
{
m_logger.Debug("the local profile is older than the remote one");
}
}
if (!userAdd(settings, username, password, "pGina created pgSMB2"))
{
userDel(settings, username, password);
return new BooleanResult() { Success = false, Message = string.Format("Unable to add user {0}", username) };
}
if (loadprofile)
{
if (!GetProfile(ref settings, username, password))
{
return new BooleanResult() { Success = false, Message = string.Format("Unable to get the Profile {0} from {1}", settings["Filename"], settings["RoamingSource"]) };
}
if (!Connect2share(settings["SMBshare"], null, null, 0, true))
{
m_logger.WarnFormat("unable to disconnect from {0}", settings["RoamingSource"]);
}
if (!SetACL(settings["UserProfilePath"], username, password, Convert.ToUInt32(settings["MaxStore"]), Convert.ToUInt32(settings["ConnectRetry"])))
{
userDel(settings, username, password);
return new BooleanResult() { Success = false, Message = string.Format("Unable to set ACL for user {0}", username) };
}
}
}
else
//.........这里部分代码省略.........
示例5: LogWarning
/// <summary>
/// Logs the warning.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="provider">The provider.</param>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public static void LogWarning( Type type, IFormatProvider provider, string format, params object[] args )
{
Log = LogManager.GetLogger ( type );
Log.WarnFormat ( provider, format, args );
}
示例6: WarnFormat
/// <summary>
/// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
/// </summary>
/// <param name="format">A String containing zero or more format items</param>
/// <param name="args">An Object array containing zero or more objects to format</param>
/// <param name="log">The log.</param>
/// <overloads>Log a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.</overloads>
/// <remarks>
/// <para>
/// The message is formatted using the <c>String.Format</c> method. See
/// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
/// of the formatting.
/// </para>
/// <para>
/// This method does not take an <see cref="T:System.Exception"/> object to include in the
/// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object)"/>
/// methods instead.
/// </para>
/// </remarks>
/// <seealso cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/>
/// <seealso cref="P:log4net.ILog.IsWarnEnabled"/>
public static void WarnFormat(string format, object[] args, ILog log)
{
log.WarnFormat(CultureInfo.InvariantCulture, format, args);
}